Technology

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

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);
}
}
 

One thought on “How to check if directory exists in specified path and then create directory

Leave a Reply

Your email address will not be published. Required fields are marked *