ChDir Statement |
No
ChDir path
path
Use: Required
Data Type: String
Any expression capable of conversion to a Date.
Changes the current working (default) directory.
Path can be an absolute or relative reference.
On Windows systems, changing the default directory doesn't change the default drive; it changes only a particular drive's default directory.
sNewDir = "c:program filesmy folder" ChDir sNewDir ... ChDir ".." 'c:program files is now the default directory.
Remember that on the Apple Power Macintosh, the relative notation "::" moves to the next higher folder, whereas on Windows 95 and NT, the notation is "..".
On Windows systems, the relative notation "." represents the current directory.
On Windows systems, the relative notation ".." represents the parent of the current directory. If the root directory is the current directory, the statement:
ChDir ".."
doesn't change the current directory and doesn't produce a syntax error.
On the Apple Power Macintosh, ChDir changes both the default directory and the default drive.
On Windows systems, the current drive is unaffected by ChDir. For instance, if the current drive is C: and you issue the statement:
ChDir "D:MyFolder"
the current directory on drive D: is changed to D:MyFolder, but the current drive is still C:.
If path isn't found, a trappable error, 76, "Path not found," is generated. However, if path refers to another machine on the network, error 75, "Path/File access error," is generated.
Although you can use a network path such as \NTSERV1d$TestDir to change the current directory on the network admin share \NTSERV1d$, you can't access this drive using ChDrive without having the drive mapped to a drive letter, which makes using network paths with ChDir a little pointless!
Use CurDir to determine the current default directory for a particular drive.
If you are using VB6, you will find that the new File System objects offer much more flexibility than the intrinsic drive and directory statements.
3.21.105.193