Directory.CreateDirectory Method |
System.IO.Directory
Directory.CreateDirectory( path )
The path of the new directory
None
Creates a new directory
path must represent a legal path.
path can be an absolute or a relative path. For example:
Directory.CreateDirectory("C:\Temp")
specifies an absolute path (it begins with a drive's root directory), while:
Directory.CreateDirectory("..\Chapter2")
is a relative path that begins from the current directory. Relative paths can make use of the "." and ".." characters , which represent the current directory and the parent of the current directory, respectively.
The CreateDirectory method creates all directories required to create a specified path. For example, the code:
Directory.CreateDirectory("c:\NewDirectory\NewSubDirectory")
will create the NewDirectory folder if it does not exist and then the newSubDirectory folder if it does not exist.
path can be either a path on the local system, the path of a mapped network drive, or a UNC path.
The CreateDirectory method does not raise an error if the directory to be created already exists.