standard.C.io._chdir

_chdir is available since version 1.0.

Prototype:

number _chdir(string dirname)

Parameters

dirname
[in] Path of new working directory

Description:

The _chdir function changes the current working directory to the directory specified by dirname. The dirname parameter must refer to an existing directory. This function can change the current working directory on any drive. If a new drive letter is specified in dirname, the default drive letter will be changed as well. For example, if A is the default drive letter and \BIN is the current working directory, the following call changes the current working directory for drive C and establishes C as the new default drive.

When you use the optional backslash character (\) in paths, you must place two backslashes (\\) in a C string literal to represent a single backslash (\).

Return value:

These functions return a value of 0 if successful. A return value of -1 indicates that the specified path could not be found.

Example
// Only on Win32 Servers !!
_chdir("c:\\temp"); 
// or
_chdir("c:/temp"); // (recommended)


// on ANY server
_chdir("/temp");