ObjectPascal
DirectoryExists
Function
Returns true if the given directory exists SysUtils unit
 function DirectoryExists ( const DirectoryName : string ) : Boolean;
Description
The DirectoryExists function returns True if the given DirectoryName file exists.
 
The directory is searched for in the current directory.
 
False may be returned if the user is not authorised to see the file.
 
Example code : Check for a directory before and after deleting it
var
  dirName : String;

begin
  // Create a new directory
  dirName := 'Test Folder';
  CreateDir(dirName);

  // Now see if the directory exists
  if DirectoryExists(dirName)
  then ShowMessage(dirName+' exists OK')
  else ShowMessage(dirName+' does not exist');

  // Delete the directory and look again
  RemoveDir(dirName);
  if DirectoryExists(dirName)
  then ShowMessage(dirName+' still exists!')
  else ShowMessage(dirName+' no longer exists');
end;
Show full unit code
   Test Folder exists OK
   Test Folder no longer exists