Get file attribute : File Attributes : File Stream C# Source Code


Custom Search

C# Source Code » File Stream » File Attributes »

 

Get file attribute









    

    using System;
    using System.IO;
    
    static class Test
    {
        static void Main()
        {
            FileInfo file = new FileInfo("test.cs");

            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).");
            }
        }
    }



           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo File Stream
» File Attributes