Solved

Delete Files

Posted on 2001-07-19
4
138 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

Independent Software Vendors: 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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