CD | CHDIR Command
Changes the default Visual FoxPro directory to the directory you specify.
CD cPath | CHDIR cPath
- Specifies one of the following:
- A drive designator.
- A drive designator with a directory.
- A child directory.
- Any of the above using MS-DOS shorthand notation ( \ or ..). When you include .. to change to the parent directory, you must include a space between CD or CHDIR and the two periods.
Use CD or CHDIR to specify the default Visual FoxPro directory. Visual FoxPro searches for files in the default Visual FoxPro directory. If Visual FoxPro cannot find a file in the default directory, it then searches the Visual FoxPro path if one has been specified. Use SET PATH to specify the Visual FoxPro path.
If you create a file and don't specify where to place it, the file is placed in the default Visual FoxPro directory.
Attempts to access system directories by using a preceding "\" will generate an error. If you need to access a system directory, use the Win32 API.
In multithreaded servers, CD affects an entire process. That is, if you have instantiated multiple threads, and you use "CD MYDIR" in one thread, it affects all the threads and the process that objects are loaded in.
The following example uses MKDIR to create a new directory named
mytstdir, then CHDIR is used to change to the new directory. GETDIR( ) is used to display the directory structure, and then RMDIR is used to remove the newly created directory GETDIR( ) is used to display the directory structure again.
SET DEFAULT TO HOME( ) && Restore Visual FoxPro directory MKDIR mytstdir && Create a new directory CHDIR mytstdir && Change to the new directory = GETDIR( ) && Display the Select Directory dialog box SET DEFAULT TO HOME( ) && Restore Visual FoxPro directory RMDIR mytstdir && Remove the new directory = GETDIR( ) && Display the Select Directory dialog box
DIR or DIRECTORY Command | DIRECTORY( ) | GETDIR( ) | HOME( ) | MD | MKDIR | RD | RMDIR | SET DEFAULT | SET PATH | SYS(5) - Default Drive | SYS(2003) - Current Directory | SYS(2004) - Visual FoxPro Start Directory