Solved

Delete Files

Posted on 2001-07-19
4
133 Views
Last Modified: 2010-04-06
How can I delete files from delphi in Runtime???

Note: I don't want to use the winexec


regards

Ricardo
0
Comment
Question by:AngelFireMateo
4 Comments
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
Use DeleteFile('filename')
0
 

Expert Comment

by:lantero
Comment Utility
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
 
LVL 4

Accepted Solution

by:
YodaMage earned 30 total points
Comment Utility
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
 
LVL 1

Author Comment

by:AngelFireMateo
Comment Utility
thank's that's what I was looking for
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now