ChDir Statement

Named Arguments

No

Syntax

ChDir path


path

Use: Required

Data Type: String

Any expression capable of conversion to a Date.

Description

Changes the current working (default) directory.

Rules at a Glance

  • 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.

Example

sNewDir = "c:program filesmy folder"
ChDir sNewDir
...
ChDir ".." 'c:program files is now the default directory.

Programming Tips and Gotchas

  • 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.

See Also

ChDrive Statement, CurDir Function, MkDir Statement, Name Statement, RmDir Statement, File System Objects
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.105.193