Changes the system environment current drive to the specified drive.
The parameter Drv must be a string or expression that can represent a valid DOS file structure drive letter. The Drv may be local to the computer, or mapped from anywhere on the network connected to the computer. If Drv contains more than one letter, only the first character is used.
Note: The file system keeps track of the current drive, and the current directory of every drive. Use the CurDir statement to determine the current directory. The current drive letter can be extracted from the Left character returned in the CurDir statement.
The ChDrive statement changes the current drive but not the current directory on any drive. To change the current directory, use the ChDir statement.
A string or expression that can represent a valid DOS file structure drive letter. Drv is case insensitive and must end with a colon (:). The Drv may be local to the computer, or mapped from anywhere on the network connected to the computer. Drv is often included as part of the Path parameter.
ChDir | CurDir, CurDir$ | Dir | RmDir | MkDir
Dim strCurPath as String
strCurPath = CurDir$()' store current path as string
ChDir "\"' change to root directory of current drive
<statements>' do stuff in root directory
ChDrive "C"' change to C drive (if not already there)
<statements>' do stuff in current directory on C drive
ChDrive strCurPath' change back to previous drive
ChDir strCurPath' change back to previous path