get in file information of a directory

The Following codes set an example for getting the information of a directory in the console application using c# and .net

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO; //It is must

namespace fileInfo


class Program


static void Main(string[] args)


DirectoryInfo dirInfo = new DirectoryInfo(@"c:\");

FileInfo[] files = dirInfo.GetFiles(); // get a list of fileInfo

Console.WriteLine("Name:-Size:-Creation date:");

foreach (FileInfo file in files)




Console.WriteLine("\t" + file.CreationTime);


Console.Read();//press any key





No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: