如何判断硬盘上某文件(如;*.txt)是否存在?若存在 then 。。
若不存在,then  

解决方案 »

  1.   

    The following code prompts for confirmation before deleting a file:if FileExists(FileName) then  if MessageDlg('Do you really want to delete ' + ExtractFileName(FileName) + '?'), mtConfirmation, [mbYes, mbNo], 0, mbNo) = IDYes then 
        DeleteFile(FileName);
      

  2.   

    Tests if a specified file exists.UnitSysUtilsCategoryfile management routinesDelphi syntax:function FileExists(const FileName: string): Boolean;C++ syntax:extern PACKAGE bool __fastcall FileExists(const AnsiString FileName);DescriptionFileExists returns true if the file specified by FileName exists. If the file does not exist, FileExists returns false.
      

  3.   

    function FileExists(const FileName: string): Boolean;
      

  4.   

    If FileExists('*.txt') then  // 注意要完整的文件路径哦 !
       ... // 存在
      Else
           .... // 不存在你也可以用查找文件的函数 FindFirstFile() 、 FindNextFile() 
    详细请看帮助的..SDK..
      

  5.   

    function FileExists(const FileName: string): Boolean;