Solved

Delete Files

Posted on 2001-07-19
4
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6299694
Use DeleteFile('filename')
0
 

Expert Comment

by:lantero
ID: 6299803
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
ID: 6300058
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
ID: 6308441
thank's that's what I was looking for
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
select query - oracle 16 103
SUM 2 INTEGER ARRAYS INTO 1 10 118
Convert MS Word document to a PDF file 9 138
How to Get Images From Server to Client using App Tethering 1 58
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

710 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