Clearing the read-only flag on a file in C#
FileInfo myFile = new FileInfo(“c:\\myfile.txt”);
if ((myFile & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
// remove the read only attribute
myFile.Attributes = (FileAttributes)(Convert.ToInt32(myFile.Attributes) - Convert.ToInt32(FileAttributes.ReadOnly));
}

myFile.Attributes -= FileAttributes.ReadOnly; works as well
Comment by Scott — August 26, 2008 @ 8:24 am
awesome input, thanks Scott!
Comment by omatase — August 26, 2008 @ 10:37 am