Solved

Delete Files

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month9 days, 12 hours left to enroll

623 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