谢谢

解决方案 »

  1.   

    Determines whether a specified directory exists.UnitSysUtilsCategoryfile management routinesDelphi syntax:function DirectoryExists(const Directory: string): Boolean;C++ syntax:extern PACKAGE bool __fastcall DirectoryExists(const AnsiString Directory);DescriptionCall DirectoryExists to determine whether the directory specified by the Name 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 Name parameter is interpreted as a relative path name from the current directory.The FileCtrl unit (Windows only) also contains a DirectoryExists function. However, the FileCtrl version is deprecated, and the SysUtils version preferred, even if the code does not need to be cross-platform.
      

  2.   

    uses FileCtrl;procedure TForm1.Button1Click(Sender: TObject);
    begin
      if not DirectoryExists('c:\temp') then
        if not CreateDir('C:\temp') then
        raise Exception.Create('Cannot create c:\temp');
    end;