델파이 Delphi FileExists
파일 존재 여부 Result => True , False
Contents
1 Description
2 VCL Code Snippet
3 FMX Code Snippet
4 Uses
procedure TForm1.Button1Click(Sender: TObject);
var FileName: string;
begin
Filename:= Edit1.Text;
if SysUtils.FileExists(FileName) then
begin
if MessageDlg(('Do you really want to delete ' +
ExtractFileName(FileName) + '?'), mtConfirmation,
[mbYes, mbNo], 0, mbNo) = IDYes then
DeleteFile(FileName);
end
else
MessageDlg(('File ' +
ExtractFileName(FileName) +
' does not exist.'), mtConfirmation, [mbOK], 0);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit2.Text:= ExtractFilePath(Application.ExeName);
end;
FMX Code Snippet
var
FullFileName: string;
FileName: string;
begin
FullFileName := Edit1.Text;
FileName := ExtractFileName(FullFileName);
if FileExists(FullFileName) then
begin
TDialogService.MessageDialog(Format('Do you really want to delete "%s"?', [FileName]),
TMsgDlgType.mtConfirmation, mbYesNo,
TMsgDlgBtn.mbNo, 0,
procedure (const AResult: TModalResult)
begin
if AResult = mrYes then
DeleteFile(FullFileName);
end);
end
else
TDialogService.ShowMessage(Format('File "%s" does not exist.', [FileName]));
end;
'Delphi > 프로시저-함수' 카테고리의 다른 글
델파이 GetLastError() 함수 (0) | 2021.07.14 |
---|---|
델파이 문자열 관련 함수 (0) | 2021.07.13 |
델파이 Delphi Fillchar (0) | 2021.07.09 |
델파이 유용한 함수정리 7탄 (0) | 2021.07.08 |
델파이 유용한 함수정리 6탄 (0) | 2021.07.07 |
댓글