public void SetReadOnly(string fullName, bool readOnly)
{
FileInfo filePath = new FileInfo(fullName);
try
{
if (filePath.Exists)
{
FileAttributes attr;
if (readOnly)
{
attr = (FileAttributes)
(filePath.Attributes | FileAttributes.ReadOnly);
}
else
{
attr = (FileAttributes)
(filePath.Attributes - FileAttributes.ReadOnly);
}
File.SetAttributes(filePath.FullName, attr);
}
}
catch (IOException e)
{
System.Diagnostics.Debug.WriteLine(e.Source);
System.Diagnostics.Debug.WriteLine(e.Message);
System.Diagnostics.Debug.WriteLine(e.StackTrace);
}
}
Saturday, May 30, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment