Solved

Purging files and directories in a A:\ drive

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now