if FileExists(FileName) then if MessageDlg('Do you really want to delete ' + ExtractFileName(FileName) + '?'), mtConfirmation, [mbYes, mbNo], 0, mbNo) = IDYes then DeleteFile(FileName); 这是例子
PathStr := PathEdit.Text; if DirectoryExists(PathStr) then begin //Do Something; end else ShowMessage('Path is Invalid,you must input like"d:\mydir\"');
如下:if DirectoryExists(ExtractFilePath(strFileName)) then // 文件路径存在 else // 否则,文件路径不存在
DeleteFile(FileName);
这是例子
判断路径是否存在可用DirectoryExists, // 在FileCtrls单元里。
判断路径是否存在可用DirectoryExists, // 在FileCtrls单元里。
if DirectoryExists(PathStr)
then
begin
//Do Something;
end
else
ShowMessage('Path is Invalid,you must input like"d:\mydir\"');
// 文件路径存在
else
// 否则,文件路径不存在