Get FileInfo : File Properties : File Directory Stream C# Examples


C# Examples » File Directory Stream » File Properties »

 

Get FileInfo









    
using  System;
using  System.IO;

class  MainClass
{
        public  static  void  Main(string[]  args)
        {
                FileInfo  file  =  new  FileInfo("c:\\test.txt");

                Console.WriteLine("Checking  file:  "  +  file.Name);
                Console.WriteLine("File  exists:  "  +  file.Exists.ToString());

                if  (file.Exists)
                {
                        Console.Write("File  created:  ");
                        Console.WriteLine(file.CreationTime.ToString());
                        Console.Write("File  last  updated:  ");
                        Console.WriteLine(file.LastWriteTime.ToString());
                        Console.Write("File  last  accessed:  ");
                        Console.WriteLine(file.LastAccessTime.ToString());
                }
                
        }
}
    
   
  
   



Output

Checking file: test.txt
File exists: True
File created: 24/03/2007 7:23:12 PM
File last updated: 24/03/2007 7:23:12 PM
File last accessed: 25/03/2007 2:04:13 PM


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo File Directory Stream
» File Properties