ChDir statement changes the system environment current directory on the specified drive.
The parameter Path must be a string or expression that can represent a valid DOS file structure path value. The parameter Dir must be a string or expression that can represent a valid DOS file structure directory name. The Path and Dir parameters together, must be limited to less than 128 characters. The Path drive letter is optional, unless the directory is on another drive. The required Dir parameter must be a valid directory name.
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 ChDir statement changes the current directory but not the current drive. To change the current drive, use the ChDrive statement.
A string or expression that can represent a valid DOS file structure path value. This includes a directory name, and may include a relative or static directory or folder structure and drive letter, in the order:
[<driveletter>:][\<rootdirectoryname>][\<subdirectory> ... \<subdirectory>\] directoryname
Note that the path can be relative to the current directory. A single period represents the current directory (.), and two periods represent the parent directory of the current directory (..). For example:
A string or expression that can represent a valid DOS file structure directory name. Dir is not case sensitive. Dir is often used with the Path parameter.
ChDrive | CurDir, CurDir$ | Dir | MkDir | RmDir
Dim strPath as String
strPath = CurDir()' store current path
ChDir "\"' change to root dir on current drive
<statements>' do stuff in root directory
ChDir strPath' change back to previous path