FileSystem.ChDrive Method

Definition

Changes the current drive.

Overloads

ChDrive(Char)

Changes the current drive.

ChDrive(String)

Changes the current drive.

ChDrive(Char)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Changes the current drive.

C#
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static void ChDrive(char Drive);
C#
public static void ChDrive(char Drive);

Parameters

Drive
Char

Required. String expression that specifies an existing drive. If you supply a zero-length string (""), the current drive does not change. If the Drive argument is a multiple-character string, ChDrive uses only the first letter.

Attributes

Exceptions

Invalid drive is specified, or drive is unavailable.

Examples

This example uses the ChDrive function to change the current drive. The function throws an exception if the drive does not exist.

VB
ChDrive("D")   ' Make "D" the current drive.

Remarks

The ChDrive function requires unmanaged-code permission, which may affect its execution in partial-trust situations. For more information, see SecurityPermission and Code Access Permissions.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 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

ChDrive(String)

Source:
FileSystem.vb
Source:
FileSystem.vb
Source:
FileSystem.vb

Changes the current drive.

C#
[System.Runtime.Versioning.SupportedOSPlatform("windows")]
public static void ChDrive(string? Drive);
C#
public static void ChDrive(string Drive);

Parameters

Drive
String

Required. String expression that specifies an existing drive. If you supply a zero-length string (""), the current drive does not change. If the Drive argument is a multiple-character string, ChDrive uses only the first letter.

Attributes

Exceptions

Invalid drive is specified, or drive is unavailable.

Examples

This example uses the ChDrive function to change the current drive. The function throws an exception if the drive does not exist.

VB
ChDrive("D")   ' Make "D" the current drive.

Remarks

The ChDrive function requires unmanaged-code permission, which may affect its execution in partial-trust situations. For more information, see SecurityPermission and Code Access Permissions.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 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