Search

Create/Delete a directory

This C# code snippet first creates (makes) then deletes a directory (folder) from disk.
using System;
using System.IO;
 
class DirectoryCreation
{
   public static void Main()
   {
      string directoryString = 
         Directory.GetCurrentDirectory() +
         @"\TestDir";
      Directory.CreateDirectory (directoryString);
      Console.WriteLine ("Created: {0}", directoryString);
      Directory.Delete (directoryString);
      Console.WriteLine ("Deleted: {0}", directoryString);
   }
}