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);
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.
function FileExists(const FileName: string): Boolean;
If FileExists('*.txt') then // 注意要完整的文件路径哦 ! ... // 存在 Else .... // 不存在你也可以用查找文件的函数 FindFirstFile() 、 FindNextFile() 详细请看帮助的..SDK..
function FileExists(const FileName: string): Boolean;
DeleteFile(FileName);
... // 存在
Else
.... // 不存在你也可以用查找文件的函数 FindFirstFile() 、 FindNextFile()
详细请看帮助的..SDK..