Mono Class Library: System.IO.Directory Overview | Members

System.IO.Directory.SetCurrentDirectory Method

Sets the application's current working directory to the specified directory.

public static void SetCurrentDirectory (string path)

Parameters

path
A string containing the path to which the current working directory is set.

Exceptions

TypeReason
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more implementation-specific invalid characters.
ArgumentNullExceptionpath is null.
System.IO.FileNotFoundExceptionpath was not found.
System.IO.IOExceptionAn I/O error occurred while performing the operation.
System.IO.PathTooLongExceptionThe length of path or the absolute path information for path exceeds the system-defined maximum length.
System.Security.SecurityExceptionThe caller does not have the required permission to access unmanaged code.

Remarks

When the application terminates, the working directory is restored to its original location (the directory where the process was started).

The path argument is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.

Note: To obtain the current working directory, see Directory.GetCurrentDirectory.

On platforms that do not support this feature, this method has no effect.

Requirements

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