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?
Open File Explorer and go to the folder that contains your files. Select the file whose attributes you want to change. On the Home tab of the Ribbon, click on the Properties button. In the next dialog, under Attributes, you can set or remove the Read-only and Hidden attributes.
Read-only is a file attribute which only allows a user to view a file, restricting any writing to the file. Setting a file to “read-only” will still allow that file to be opened and read; however, changes such as deletions, overwrites, edits or name changes cannot be made.
Use SetFileAttributes again to reset the flag:
SetFileAttributes( pszFilename,
GetFileAttributes(pszFilename) & ~FILE_ATTRIBUTE_READONLY);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With