如何删除文件MFC的Readonly属性

Jij*_*hKV 10 c++ winapi mfc

在我的MFC应用程序中,我在特定文件上设置了只读属性.我是通过使用该SetFileAttributes()功能完成的.在某些时候,我必须再次删除该文件的属性.

任何人都可以解释如何做到这一点?

Ser*_*ier 24

再次使用SetFileAttributes重置标志:

SetFileAttributes( pszFilename,  
                   GetFileAttributes(pszFilename) & ~FILE_ATTRIBUTE_READONLY);
Run Code Online (Sandbox Code Playgroud)

  • GetFileAttributes() 可能会返回许多 SetFileAttributes() 函数不理解的其他标志,这安全吗?那些额外的标志会被忽略吗? (2认同)
  • 我很乐意,但它说改变1个字符是不够的,不会接受编辑. (2认同)