My.Computer.FileSystem.CurrentDirectory Property
Gets or sets the current directory.
' Usage
Dim value As String = My.Computer.FileSystem.CurrentDirectory
' Declaration
Public Property CurrentDirectory As String
Property Value
String.
Exceptions
The following conditions may cause an exception:
The path is not valid (DirectoryNotFoundException).
The user lacks necessary permissions (UnauthorizedAccessException).
Remarks
CurrentDirectory is a system-wide environment variable.
Example
This example returns the current directory and displays it in a message box.
MsgBox(My.Computer.FileSystem.CurrentDirectory)
This example sets the current directory to C:\TestDirectory.
My.Computer.FileSystem.CurrentDirectory = "C:\TestDirectory"
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
Permissions may not be necessary to set CurrentDirectory.
The following permission may be necessary to read CurrentDirectory:
Permission |
Description |
---|---|
Controls the ability to access files and folders. Associated enumeration: Unrestricted. |
For more information, see Code Access Security and Requesting Permissions.