CHDIR statement


Change the current (default) directory on the default drive, or any other drive (similar to the DOS CHDIR command).  CHDIR affects only the default drive for the current program.


CHDIR path


path is a string expression containing either a relative or an explicit directory name.  The directory name can be constructed from a (DOS-Style) Short File Name (SFN) directory name, a Long File Name (LFN) directory name, or a combination of the two.  Also, path may be prefixed with a drive letter and colon (i.e., "D:") to change the current directory on a non-default drive.

The current directory is the location where your program will perform file operations by default.  Thus:


changes to the \DATA subdirectory on the current drive, and:


changes the current directory to a directory whose parent is also the parent to the original directory.  The double-period implies the parent directory.

CHDIR "J:\Program Files\Internet Explorer"

changes the current directory of Drive J.  Drive J need not be the current default drive.

If path does not specify a valid directory on the target drive, a run-time Error 76 occurs ("Path not found").

A program that changes the current directory on the default drive also changes its active directory.

path may also be used with UNC names (i.e., \\server\share), but their use is subject to operating system restrictions.


CHDIR is not intended to change the current default drive.  Use CHDRIVE instead.

See also