Solved

Purging files and directories in a A:\ drive

Posted on 1998-12-08
2
167 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
  • 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 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