xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

DirChange()

Changes the current directory.

Syntax

DirChange( <cDirectory> ) --> nOSError

Arguments

<cDirectory>
A character expression specifying the directory to select as the current directory. The directory may include a drive letter followed by a colon.

Return

The function returns a numeric value representing the operating system error code (DOS error). A value of 0 indicates a successful operation.

Description

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.

Info

See also:DirRemove(), DiskChange(), DiskName(), FError(), IsDisk(), MakeDir()
Category: Directory functions , File functions
Source:rtl\dirdrive.c
LIB:xhb.lib
DLL:xhbdll.dll

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe