To create, move and delete directories in C#, the System.IO.Directory class has methods.
First, import the System.IO namespace.
Now, use the Director.CreateDirectory() method to create a directory in the specified path -
string myDir = @"D:\NEW"; if (!Directory.Exists(myDir)) { Directory.CreateDirectory(myDir); }
Similarly, you can create a subdirectory −
string mysubdir = @"C:\NEW\my\"; Directory.CreateDirectory(mysubdir);
The above is the detailed content of How to create a directory using C#?. For more information, please follow other related articles on the PHP Chinese website!