比如我在c:\yyp下有个文件yyp.txt,那我如何判断yyp.txt文件存在?  请给出代码。谢谢!

解决方案 »

  1.   

    if fileExists('C:\yyp\yyp.txt')=true then 
    begin
          {文件存在};
    end
    else
    begin
         {文件不存在的处理}
    end;
      

  2.   

    if fileExists('C:\yyp\yyp.txt') then 
    begin
          {文件存在};
    end
    else
    begin
         {文件不存在的处理}
    end;
      

  3.   

    //当button被选中,由Edit指定的文件名在当前路径和Windows路径中被查找。
    procedure TForm1.Button1Click(Sender:TObject);
    var
        buffer:array[0..255] of char;
        FileToFind:string;
    begin
        GetWindowsDirectory(buffer,SizeOf(buffer));
        FileToFind:=FileSearch(Edit1.Text,GetCurrentDir+';'+buffer);
        if FileToFind='' then
            showmessage('Couldn''tfind'+Edit1.text+'.')
        else
            showmessage('Found'+FileToFind+'.');
    end;
      

  4.   

    if fileExists('C:\yyp\yyp.txt') then