Hi all *.*
I want to know if a file is readonly or not please tell me how to do that (Csharp )
How To know if a File Is readOnly ?
Urgent
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Vandita PandeyPosted Aug 14, 2006, 8:33 AM
Using GetAttributes method you can check the fileattributes of a file.
Check the code snippet below :
string path = @"c:\temp\MyTest.txt";
// Ensure that the file is readonly.
if ((File.GetAttributes(path) & FileAttributes.ReadOnly)== FileAttributes.ReadOnly)
{
// some code here
}