In the Delphi program, to delete a file we can use the function: DeleteFile (const FileName: string): Boolean;
Example:
Create a Form with an Edit, 1 OpenDialog and 2 Button. Perform double-clicking the Button1 component and button2, write the following program listing:
procedure TF_DeleteFile.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then Edit1.Text:=OpenDialog1.FileName;
end;
procedure TF_DeleteFile.Button2Click(Sender: TObject);
begin
if Deletefile(pchar(Edit1.Text))=true
then showmessage('Managed to copy a file')
else showmessage('Failed to copy file');
end;
No comments:
Post a Comment