if fileexists("aa.txt")then
begin
//dothis
end else begin
//doelse
end
或者
if filexists(extractfilepath(application.exename))+"aa.txt") then
begin
//dothis
end else begin
//doelse
end

解决方案 »

  1.   

    if FileExists('aa.txt') then //如果文件存在
      

  2.   

    Var
      Directory: array[0..99] of char;
      FileName: String;
      Len: Integer;
    begin
      GetCurrentDirectory(Len, @Directory[0]) //获得当前目录
      Directory[Len]:= #0;
      FileName:= StrPas(@Directory[0]) + 'aa.txt';
      if FileExists(FileName) then //如果存在
      begin
        
      end
      else
        Close(); 
    end;
      

  3.   

    if fileExists('.\aa.txt') then begin
     do something
    end
    else begin
     do something
    end;
      

  4.   

    The FindFirstFile function searches a directory for a file whose name matches the specified filename. FindFirstFile examines subdirectory names as well as filenames. HANDLE FindFirstFile(
      LPCTSTR lpFileName,  // pointer to name of file to search for
      LPWIN32_FIND_DATA lpFindFileData 
                           // pointer to returned information
    );Return Values
    If the function succeeds, the return value is a search handle used in a subsequent call to FindNextFile or FindClose.If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call GetLastError. 
      

  5.   

    用FileExists,
    获得当前目录用GetCurrentDirectory
    获得本程序运行目录用ExtractFilePath(Application.ExeName)