Solved

Purging files and directories in a A:\ drive

Posted on 1998-12-08
2
168 Views
Last Modified: 2012-05-04
Anyone knows how to write delphi codes to purge all files and directories from the diskette in Delphi 3 ?
0
Comment
Question by:n_chai
[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
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1349969
Answer coming...
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1349970
n_chai,

Do something like this which recursively deletes all files and directories.

procedure KillAllFiles(FilePath : String);

var
  SearchRec : TSearchRec;

begin
//first kill the directories (recursively)

  FindFirst(filepath, faDirectory, SearchRec);
  repeat
    KillAllfiles(ExtractFilepath(FilePath) + '\' + searchrec.name + '\*.*')
  until (FindNext(SearchRec) = 0)

  FindClose(SearchRec);

// Now kill the files

  FindFirst(filepath, faAnyFile, SearchRec);
  repeat
     deletefile(ExtractFilePath(Filepath)+ '\' + searchrec.name)
  until FindNext(SearchRec) = 0;

   FindClose(SearchRec);
end;

call it like this:

Killallfiles('a:\*.*');

Cheers,

Raymond.


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
Delphi Form ownership 4 127
Error E2158 compiling with Delphi XE10 Seattle 2 127
Delphi: Connect to running MS Outlook 4 165
How to load 2 images in same column in Delphi 2 68
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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