1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
/// <summary>
/// Sets the read only attribute.
/// </summary>
/// <param name="fullName">The full name.</param>
/// <param name="readOnly">if set to <c>true</c> [read only].</param>
private static void SetReadOnlyAttribute(string fullName, bool readOnly)
{
FileInfo filePath = new FileInfo(fullName);
FileAttributes attribute;
if (readOnly)
attribute = filePath.Attributes | FileAttributes.ReadOnly;
else
attribute = (FileAttributes) (filePath.Attributes - FileAttributes.ReadOnly);
File.SetAttributes(filePath.FullName, attribute);
}
|