System.IO.Directory.GetCurrentDirectory Method

Gets the current working directory of the application.

Syntax

public static string GetCurrentDirectory ()

Returns

A string that contains the path of the current working directory, and does not end with a backslash (\).

Exceptions

TypeReason
System.Security.SecurityExceptionThe caller does not have the required permission.
UnauthorizedAccessExceptionThe caller does not have the required permission.

Remarks

The current directory is distinct from the original directory, which is the one from which the process was started.

For a list of common I/O tasks, see Common I/O Tasks.

Permissions

TypeReason
System.Security.Permissions.FileIOPermissionRequires permission to access path information for the current directory. See System.Security.Permissions.FileIOPermissionAccess.PathDiscovery

Requirements

Namespace: System.IO
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0