To create a directory in C#, you can use the Directory.CreateDirectory
method. This method takes a string parameter that represents the path and name of the directory to be created. Here is an example:
main.cs69 chars3 lines
This code creates a new directory named "MyNewDirectory" at the root of the C: drive.
You can also use the DirectoryInfo
class to create a directory. Here is an example:
main.cs88 chars3 lines
This code creates a new directory named "MyNewDirectory" at the root of the C: drive and stores the directory info in a DirectoryInfo
object.
It is important to note that if the directory already exists, the CreateDirectory
method will not do anything and will not throw an exception.
gistlibby LogSnag