Is there a way to remove read-only attribute of a file if the user is not an administrator?
This works if you're an admin but what if you're not?
FileInfo myFile = new FileInfo(pathToFile);
myFile.IsReadOnly = false;
You need to have read/write permission on the file.
I preferably use a method like this:
FileSystemInfo fsi = new FileSystemInfo(pathToFile);
fsi.Attributes = FileAttributes.Normal;
or
File.SetAttributes(pathToFile, FileAttributes.Normal);
But as I've said, this won't be possible without read/write permissions on the specific file.
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