Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Use the CreateDirectory method of the My.Computer.FileSystem object to create directories.
If the directory already exists, no exception is thrown.
To create a directory
Use the CreateDirectory method by specifying the full path of the location where the directory should be created. This example creates the directory NewDirectory in C:\Documents and Settings\All Users\Documents.
My.Computer.FileSystem.CreateDirectory _ ("C:\Documents and Settings\All Users\Documents\NewDirectory")
Robust Programming
The following conditions may cause an exception:
The directory name is malformed. For example, it contains illegal characters or is only white space (ArgumentException).
The parent directory of the directory to be created is read-only (IOException).
The directory name is Nothing (ArgumentNullException).
The directory name is too long (PathTooLongException).
The directory name is a colon ":" (NotSupportedException).
The user does not have permission to create the directory (UnauthorizedAccessException).
The user lacks permissions in a partial-trust situation (SecurityException).
See Also
Tasks
How to: Determine if a Directory Exists in Visual Basic
Reference
My.Computer.FileSystem.CreateDirectory Method
Other Resources
Creating, Deleting, and Moving Files and Directories in Visual Basic