我很久以前在某个地方读到了一个Delphi的最佳实践。
这是不推荐的写法:
if FileExists(MyFile) then begin
if not DeleteFile(MyFile) then
ShowMessage('Unable to delete file');
end;
请写下以下内容:
if not DeleteFile(MyFile) then
ShowMessage('Unable to delete file');
第二个的优缺点是什么?