Solved

Purging files and directories in a A:\ drive

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
A short film showing how OnPage and Connectwise integration works.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 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

10 Experts available now in Live!

Get 1:1 Help Now