CSharp examples for File IO:File
Set File and Directory Attributes
using System;//from www. j av a2 s. co m using System.IO; static class Recipe05_02 { static void Main() { FileInfo file = new FileInfo(@"C:\Windows\win.ini"); Console.WriteLine(file.Attributes.ToString()); if (file.Attributes == FileAttributes.ReadOnly) { Console.WriteLine("File is read-only (faulty test)."); } if ((file.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { Console.WriteLine("File is read-only (correct test)."); } } }