How to Remove the Readonly attribute of a File MFC
11,440
Use SetFileAttributes again to reset the flag:
SetFileAttributes( pszFilename,
GetFileAttributes(pszFilename) & ~FILE_ATTRIBUTE_READONLY);
Author by
JijeshKV
Updated on June 05, 2022Comments
-
JijeshKV almost 2 years
In my MFC application I have set the read only attribute on a particular file. I have done this by using the
SetFileAttributes()
function. At some point I have to remove that attribute of that file again.Can anyone explain how to do this?
-
Alexis Wilke over 11 yearsGetFileAttributes() may returned many other flags that the SetFileAttributes() function doesn't understand, is that safe? Will those extra flag be ignored?
-
paulm about 11 years2nd call has a typo, File not Files :)
-
Serge Wautier about 11 years@paulm: Feel free to fix it. That's why SO is a wiki! OK, did it.
-
paulm about 11 yearsI'd love to, but it says changing 1 char is not enough and won't accept the edit.