This documentation is archived and is not being maintained.

FileSystem.ChDrive Method (Char)

Changes the current drive.

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public static void ChDrive(
	char Drive
)

Parameters

Drive
Type: System.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.

For more detailed information, see the Visual Basic topic ChDrive Function.

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

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

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0
Show: