My.Computer.FileSystem.CreateDirectory MethodÂ
Creates a directory.
' Usage
My.Computer.FileSystem.CreateDirectory(directory)
' Declaration
Public Sub CreateDirectory( _
ByVal directory As String _
)
Parameters
- directory
String. Name and location of the directory. Required.
Exceptions
The following conditions may cause an exception:
The directory name is malformed. For example, it contains illegal characters or is only white space (ArgumentException Class).
The parent directory of the directory to be created is read-only (IOException Class).
The directory name is Nothing (ArgumentNullException Class).
The directory name is too long (PathTooLongException Class).
The directory name is only a colon (:). (NotSupportedException Class).
The user does not have permission to create the directory (UnauthorizedAccessException).
A partial-trust situation exists in which the user does not have sufficient permissions (SecurityException).
Remarks
If the directory already exists, no exception is thrown.
Tasks
The following table lists examples of tasks involving the My.Computer.FileSystem.CreateDirectory method.
To | See |
---|---|
Create a directory |
Example
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")
Requirements
Namespace: Microsoft.VisualBasic.MyServices
Class: FileSystemProxy (provides access to FileSystem)
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)
Availability by Project Type
Project type | Available |
---|---|
Windows Application |
Yes |
Class Library |
Yes |
Console Application |
Yes |
Windows Control Library |
Yes |
Web Control Library |
Yes |
Windows Service |
Yes |
Web Site |
Yes |
Permissions
The following permission may be necessary:
Permission | Description |
---|---|
Controls the ability to access files and folders. Associated enumeration: Unrestricted. |
For more information, see Code Access Security and Requesting Permissions.
See Also
Tasks
How to: Determine if a Directory Exists in Visual Basic