User forums > Using Code::Blocks

How to give write permission to a windows file from c code

(1/1)

mrsudhi:
I have written a C program, one of the operation it does is copying contents from one file to other.
The original file is usually a read only file.
If the file is read only, the the copy of file just doesn't happen, but if I manually give read permission to the file it works fine.

In unix, I know I can call system(chmod 777 abc.c) to give write permission to file.
But my question is how can I achieve this in windows?
i.e. how can I give write permission to a windows file from C code?

Thanks in advance.

Radek:
You need to create a (new) r/w file, read the contents of the source and write it to the target. You must pass if the source can be read. A "high level copy" can copy permissions, too, something you must avoid. But this is not a Code Blocks related problem.

Jenna:
Unrelated to C::B and therefore violating our forum rules.

Topic locked !

Navigation

[0] Message Index

Go to full version