How to get file length, size, info and creation time in a directory in C#

1 Answer

0 votes
using System;
using System.IO; 

namespace File_Info
{
	class Class1
	{
		static void Main(string[] args)
		{
            DirectoryInfo di = new DirectoryInfo(@"d:\wwwroot");

            FileInfo[] files = di.GetFiles("*.php");

            foreach (FileInfo f in files)
            { 
				string name = f.FullName; 
				long size = f.Length; 
				DateTime creationTime = f.CreationTime;
                Console.WriteLine("{0,-12:N2} {1,-20:g} {2}", size, creationTime, name);
            } 		
		}
	}
}



answered Aug 21, 2014 by avibootz
...