How to check if directory exists in specified path and then create directory

By | 20th November 2017
The following code illustrates on how to check if directory exists in specific path, if not then create directory.
Here I show that how to create the directory with simple condition.
 
 
private void TestDirectory()
{
    string pathname = “C:\\Myfolder”;
   
    if(!Directory.Exists(pathname))
{
    Directory.CreateDirectory(pathname);
}
}