RAD Studio VCL Reference
|
Determines whether a specified directory exists.
function DirectoryExists(const Directory: string): Boolean;
Boolean DirectoryExists(const AnsiString Directory);
Call DirectoryExists to determine whether the directory specified by the Directory parameter exists. If the directory exists, the function returns true. If the directory does not exist, the function returns false.
If a full path name is entered, DirectoryExists searches for the directory along the designated path. Otherwise, the Directory parameter is interpreted as a relative path name from the current directory.
C++ Examples:
/* The following example creates a directory ‘C:\temp’ if it does not already exist. } */ #include <Filectrl.hpp> void __fastcall TForm1::Button1Click(TObject *Sender) { if (!DirectoryExists("c:\\temp")) { if (!CreateDir("C:\\temp")) throw Exception("Cannot create c:\\temp directory."); } if (!CreateDir("C:\\temp")) throw Exception("Cannot create C:\\temp again!"); }
Delphi Examples:
{ The following example creates a directory ‘C:\temp’ if it does not already exist. } uses FileCtrl; procedure TForm1.Button1Click(Sender: TObject); begin if not SysUtils.DirectoryExists('C:\temp') then if not CreateDir('C:\temp') then raise Exception.Create('Cannot create C:\temp'); if not CreateDir('C:\temp') then raise Exception.Create('Cannot create C:\temp again!'); end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|