find the creation date of a directory in csharp

Here is a code snippet that retrieves the creation date of a directory in C#:

main.cs
using System;
using System.IO;

class Program {
  static void Main(string[] args) {
    DirectoryInfo directoryInfo = new DirectoryInfo(@"C:\example_directory");
    DateTime creationTime = directoryInfo.CreationTime;
    Console.WriteLine("Directory creation time: " + creationTime);
  }
}
291 chars
11 lines

In this code, we create a DirectoryInfo object that points to the directory we want to inspect. We can then use the CreationTime property of this object to get the creation time of the directory as a DateTime object. We can then use this value as needed in our program.

gistlibby LogSnag