if FileExists('路径') then  MessageBox(0,'存在','提示',MB_OK);    //判断文件是否存在 if DirectoryExists('路径') then  MessageBox(0,'存在','提示',MB_OK);    //判断文件夹(路径)是否存在 

解决方案 »

  1.   

     function IsValidFilePath(const FileName: String): Boolean;
      var
        S: String;
        I: Integer;
      begin
        Result := False;
        S := FileName;
        repeat
          I := LastDelimiter('\/', S);
          MoveFile(nil, PChar(S));
          if (GetLastError = ERROR_ALREADY_EXISTS) or
             (
               (GetFileAttributes(PChar(Copy(S, I + 1, MaxInt))) = INVALID_FILE_ATTRIBUTES)
               and
               (GetLastError=ERROR_INVALID_NAME)
             ) then
            Exit;
          if I>0 then
            S := Copy(S,1,I-1);
        until I = 0;
        Result := True;
      end;