FileSystem.CurrentDirectory Property

Definition

Gets or sets the current directory.

C#
public static string CurrentDirectory { get; set; }

Property Value

The current directory for file I/O operations.

Exceptions

The path is not valid.

The user lacks necessary permissions.

Examples

This example returns the current directory and displays it in a message box.

VB
MsgBox(My.Computer.FileSystem.CurrentDirectory)

This example sets the current directory to C:\TestDirectory.

VB
My.Computer.FileSystem.CurrentDirectory = "C:\TestDirectory"

Remarks

CurrentDirectory is a system-wide environment variable.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1