| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Changes the current directory.
DirChange( <cDirectory> ) --> nOSError
The function returns a numeric value representing the operating system error code (DOS error). A value of 0 indicates a successful operation.
The function attempts to change the current directory to the one specified with <cDirectory>. If this operation fails, the function returns the OS error code indicating the reason for failure. See the FError() function for a description of OS errors.
| See also: | DirRemove(), DiskChange(), DiskName(), FError(), IsDisk(), MakeDir() |
| Category: | Directory functions , File functions |
| Source: | rtl\dirdrive.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example changes to existing and non-existing directories.
PROCEDURE Main
LOCAL cCurDir := CurDrive() + ":\" + CurDir()
? DirChange( "c:\temp" ) // result: 0
? DirChange( ".\data" ) // result: 2
? DirChange( cCurDir ) // result: 0
RETURN
http://www.xHarbour.com