How to Remove the Readonly attribute of a File MFC

2019-02-08 22:18发布

问题:

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?

回答1:

Use SetFileAttributes again to reset the flag:

SetFileAttributes( pszFilename,  
                   GetFileAttributes(pszFilename) & ~FILE_ATTRIBUTE_READONLY);


标签: c++ winapi mfc