c - Testing if a file/directory is read only -


OK, so I'm a bit of a newbie

I work with some GetFileAttributes function Tried, but to no avail.

Looking at the path of a file, what is the correct way to test if it is read only?

Edit:

So I'm still stuck on this one. I want to know whether or not the user has permission to add or edit files in C: \ program file ... and I can not find any advice for working.

When I use! (GetFileAtrributes (Path) and FILE_ATTRIBUTES_READONLY), this indicates that the directory is not read-only. I then tried to write and test the file if it worked:

  strcat (path, "\\ testFile000"); File * test = 0; Test = FOPN (path, "W"); Int i = fwrite ("ab", 1, sizeof ("ab"), test);  

But when I'm testing this, I do not see any file in the == 3 and OS.

Any thoughts?

GetFileAttributes is the perfect Windows call - see for use

Example test only Read and check check is dwAttrs & amp; FILE_ATTRIBUTE_READONLY and if that file is read-only then it will not be zero.


Comments