This example shows how to bounce the path if exists, otherwise create a directory. If you write subdirectories like "c:\mydir\a\b", it will create directories asas directed

using System;
using System.IO;
//csc directoryinfo_exists_delete.cs
namespace dir_files
public class dir_create
public static void procces( string s )

string path = s;
// Determine whether the directory exists.
if (Directory.Exists(path))
{ Console.WriteLine("That path exists already.");
Console.WriteLine("Root directory: {0}", Directory.GetDirectoryRoot(path));
Console.Write("Would Like to delete yes/no :");
string str_yes =Console.ReadLine();
//nested if starts
if(str_yes =="yes") { Directory.Delete(path, true);
Console.WriteLine("directory " + path + "deleted.");
return; } //end of if
// if it is a new directory path
DirectoryInfo root = Directory.CreateDirectory(path);
Console.WriteLine("The directory was created at {0}.", Directory.GetCreationTime(path));

catch (Exception e)
Console.WriteLine("The process failed: {0}", e.ToString());
finally {}

}//end of the class

class Test
public static void Main()
Console.Write(" Enter complete path :");
string str =Console.ReadLine();
if(str !=""){ dir_create.procces(str);}
else return;
} while(true);

Current directory

directory was deleted

Let us recreate the directory again, as double check

Note the time when the directory "my_dir_1" was recreated

The above routine is also good to create new subdirectories. (This eliminates the use of an old class " CreateSubDirectories")