Environment.CurrentDirectory Property

Gets or sets the fully qualified path of the current directory; that is, the directory from which this process starts.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static string CurrentDirectory { get; set; }
/** @property */
public static String get_CurrentDirectory ()

/** @property */
public static void set_CurrentDirectory (String value)

public static function get CurrentDirectory () : String

public static function set CurrentDirectory (value : String)

Property Value

A string containing a directory path.

Exception typeCondition


Attempted to set to an empty string ("").


Attempted to set to a null reference (Nothing in Visual Basic).


An I/O error occurred.


Attempted to set a local path that cannot be found.


The caller does not have the appropriate permission.

By definition, if this process starts in the root directory of a local or network drive, the value of this property is the drive name followed by a trailing slash (for example, "C:\"). If this process starts in a subdirectory, the value of this property is the drive and subdirectory path, without a trailing slash (for example, "C:\mySubDirectory").

The following code example demonstrates setting the CurrentDirectory property.

// Change the directory to %WINDIR%                            
Environment.CurrentDirectory = Environment.GetEnvironmentVariable("windir");        
DirectoryInfo info = new DirectoryInfo(".");
    Console.WriteLine("Directory Info:   "+info.FullName);

// Change the directory to %WINDIR%                            

DirectoryInfo info = new DirectoryInfo(".");

synchronized(info) {
    Console.WriteLine(("Directory Info:   " + info.get_FullName()));

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions