Delete Files

How can I delete files from delphi in Runtime???

Note: I don't want to use the winexec


regards

Ricardo
LVL 1
AngelFireMateoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
YodaMageConnect With a Mentor Commented:
Even with permissions and FileExists, you also need to be sure that file is not in use, hence an exception raised from the share.

Try
 if FileExists('C:/temporal/file.txt') then
 DeleteFile('C:/temporal/file.txt')
else
 MessageDlg('File Not Found', mtWarning, [mbOK], 0);
except
 MessageDlg('Operation Failed', mtWarning, [mbOK], 0);
end;




0
 
EpsylonCommented:
Use DeleteFile('filename')
0
 
lanteroCommented:
uses SysUtils;

....

// erase the file //

 DeleteFile('C:/temporal/file.txt');

ensure that the file exists with the function

 FileExists(filename: string): boolean;

and take care the file permissions if you are under NT.
0
 
AngelFireMateoAuthor Commented:
thank's that's what I was looking for
0
All Courses

From novice to tech pro — start learning today.