谢谢

解决方案 »

  1.   

    if FileExists('C:\test.txt') then
      // ...
      

  2.   

    var ok :boolean;
    ok := FileExists('C:\test.txt');
      

  3.   

    var
    SearchRec: TSearchRec;
    procedure TForm1.SearchClick(Sender: Tobject);
    begin
    FindFirst('c:\Program Files\delphi3\bin\*.*', faAnyFile, SearchRec);
    Label1.Caption := SearchRec.Name + ' is ' + IntToStr(SearchRec.Size) + ' bytes in size';
    end;
    procedure TForm1.AgainClick(Sender: Tobject);
    begin
    if (FindNext(SearchRec) = 0)
    Label1.Caption := SearchRec.Name + ' is ' + IntToStr(SearchRec.Size) + ' bytes in size';else
    FindClose(SearchRec);
    end;
      

  4.   

    var Con:string;// 当前目录
        StrName:string;//文件名称
        F:array[0..255] of char;
    begin
      getcurrentdirectory(F,sizeof(f));
      con:=f;
      if fileexists(F+'\'+strName) then .....
      else .....
    end;
      

  5.   

    简单的方法
    dirlist-你的目录名
    function FileSearch(const Name, DirList: string): string;