Function CurDirectory() Foundation

Determines or changes the current directory of the process.

Syntax
CurDirectory( [<cDirectory>] ) --> cPreviousDirectory
Parameters
<cDirectory>
The optional parameter <cDirectory> contains the new current directory of the process. The directory can be specified using a relative or an absolute path. In an absolute path, the disk designator may be specified via a drive letter followed by a colon ("e:"), or it can be specified via server and share name ("\\servername\sharename"). In the case of a relative path, the new current directory is calculated from the directory currently set. In any case, a runtime error is raised if the specified directory does not exist.
Return

The return value of CurDirectory() is a string containing the previous current directory. It is specified as an absolute path without a trailing backslash character ("\"). If no argument is passed to the function, it returns the current directory.

Description

The environment function CurDirectory() determines the current directory of the process. If a directory is specified in the <cDirectory> parameter, this directory becomes the process' new current directory. CurDirectory() correctly handles relative and absolute paths, including UNC paths.

The current directory is a global setting for the process, so changing the current directory in one thread also affects all other threads. Therefore, CurDirectory() should be used with care in applications using multiple threads. In shared libraries, the function should be avoided completely.

Examples
Determining and changing the current directory
PROCEDURE Main 

// Read current directory 
? CurDirectory()                   // result: (project directory) 

// Change current directory 
? CurDirectory("\\abraxas\store")  // result: (project directory) 
? CurDirectory("c:\tmp")           // result: "\\abraxas\store" 
? CurDirectory("sub-dir")          // result: "c:\tmp" 
? CurDirectory()                   // result: "c:\tmp\sub-dir" 
? CurDirectory( "invalid-dir" )    // result: (runtime error) 

RETURN 
Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.