C# create directory

C# create directory

In order to create directory in C# it's advised to check existence of directory if directory wasn't exist then create it.


Here is how to?

if(!System.IO.Directory.Exists(@"C:\\Irando"))
{
 System.IO.Directory.CreateDirectory(@"C:\\Irando");
}

Note: Remember you need to use using System.IO; in top of your windows form.

What code above does is, first check if folder named Irando is exist in drive C then if it doesn't exist, create it.

And that's it.

- Last updated 3 weeks ago

Be the first to leave a comment.

You must login to leave a comment