DelphiBasics
SetCurrentDir
Function
Change the current directory SysUtils unit
 function SetCurrentDir(const Dir string):Boolean;
Description
The SetCurrentDir function sets the current directory to Dir, returning True if successful.
 
If the directory does not exist, then getLAstError can be used to get the error code.
Related commands
ChDirChange the working drive plus path for a specified drive
CreateDirCreate a directory
GetCurrentDirGet the current directory (drive plus directory)
GetDirGet the default directory (drive plus path) for a specified drive
MkDirMake a directory
RemoveDirRemove a directory
RmDirRemove a directory
SelectDirectoryDisplay a dialog to allow user selection of a directory
ForceDirectoriesCreate a new path of directories
 Download this web site as a Windows program.




 
Example code : Show set and re-show the current directory
begin
  // Show the current directory
  ShowMessage('Current directory = '+GetCurrentDir);

  // Change this value
  SetCurrentDir('C:\Program Files');

  // Show the current directory again
  ShowMessage('Current directory = '+GetCurrentDir);
end;
Show full unit code
  Current directory = C:\Program Files\Borland\Delphi7\Projects
  Current directory = C:\Program Files
 
Delphi Programming © Neil Moffatt . All rights reserved.  |  Home Page