Solved

To Geobul

Posted on 2001-07-01
2
152 Views
Last Modified: 2010-08-05
To Geobul

Hello
I have problem with the stop funktion you made for me.
If I search my big hd (40gig) and set mask to a file not exist.
Like *.ggg it is almost impossible to stop the procedure.
I need this to be fixed. please help me.  

If you don?t remeber the Procedure here it is.

procedure GetFiles(FromDir, Mask: String; IncludeSubdirs : boolean; List: TListBox);
 var
 DirInfo: TSearchRec;
 R, ii, i: Integer;
 DirList: TStringList;

begin

 if FromDir[Length(FromDir)] <> '\' then FromDir := FromDir + '\';
 DirList := TStringList.Create;
try
if not StopFind then begin
 if IncludeSubdirs then begin
  R := FindFirst(FromDir + '*.*', faDirectory, DirInfo);
  if R = 0 then begin
   repeat
    if (DirInfo.Name <> '.') and (DirInfo.Name <> '..') then begin
      DirList.Add(FromDir + DirInfo.Name);

    end;
    R := FindNext(DirInfo);
   until R <> 0;
   FindClose(DirInfo);
  end;
 end;
 end;
 R := FindFirst(FromDir + Mask, faAnyfile, DirInfo);
form1.StatusBar1.Panels[2].Text:=FromDir + DirInfo.Name + '\';
 if R = 0 then begin
  repeat
      if not StopFind then begin
    if (DirInfo.Name <> '.') and (DirInfo.Name <> '..') then begin
      if (((DirInfo.Attr and faDirectory) <> 0) and IncludeSubdirs) then GetFiles(FromDir + DirInfo.Name
+ '\', Mask, IncludeSubdirs, List)

        else List.Items.Add(FromDir + DirInfo.Name);
      end;
    end;
    R := FindNext(DirInfo);
  until R <> 0;
  FindClose(DirInfo);
 end;
Application.ProcessMessages;
 if not StopFind then begin
  if IncludeSubdirs then begin
   for i := 0 to DirList.Count - 1 do begin
     GetFiles(DirList[i], Mask, IncludeSubdirs, List);
       for ii := 0 to form1.lbFiles.Items.Count  do begin
        form1.StatusBar1.Panels[1].Text:='Files found: ' + IntToStr(ii);
        end;
    end;
  end;
 end;
finally
  DirList.Free;
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
StopFind := true;
//form1.StatusBar1.Panels[1].Text:='';
//form1.StatusBar1.Panels[2].Text:='';
end;
0
Comment
Question by:Dark_King
2 Comments
 
LVL 14

Accepted Solution

by:
AvonWyss earned 100 total points
ID: 6243850
I'm not GeoBul, but try this:

procedure GetFiles(FromDir, Mask: String; IncludeSubdirs : boolean; List: TListBox);
var
DirInfo: TSearchRec;
R, ii, i: Integer;
DirList: TStringList;

begin

if FromDir[Length(FromDir)] <> '\' then FromDir := FromDir + '\';
DirList := TStringList.Create;
try
if not StopFind then begin
if IncludeSubdirs then begin
 R := FindFirst(FromDir + '*.*', faDirectory, DirInfo);
 if R = 0 then begin
  repeat
   if (DirInfo.Name <> '.') and (DirInfo.Name <> '..') then begin
     DirList.Add(FromDir + DirInfo.Name);

   end;
   R := FindNext(DirInfo);
  until R <> 0;
  FindClose(DirInfo);
 end;
end;
end;
R := FindFirst(FromDir + Mask, faAnyfile, DirInfo);
form1.StatusBar1.Panels[2].Text:=FromDir + DirInfo.Name + '\';
if R = 0 then begin
 repeat
     Application.ProcessMessages;
     if not StopFind then begin
   if (DirInfo.Name <> '.') and (DirInfo.Name <> '..') then begin
     if (((DirInfo.Attr and faDirectory) <> 0) and IncludeSubdirs) then GetFiles(FromDir + DirInfo.Name
+ '\', Mask, IncludeSubdirs, List)

       else List.Items.Add(FromDir + DirInfo.Name);
     end;
   end;
   R := FindNext(DirInfo);
 until R <> 0;
 FindClose(DirInfo);
end;
Application.ProcessMessages;
if not StopFind then begin
 if IncludeSubdirs then begin
  for i := 0 to DirList.Count - 1 do begin
    GetFiles(DirList[i], Mask, IncludeSubdirs, List);
      for ii := 0 to form1.lbFiles.Items.Count  do begin
       form1.StatusBar1.Panels[1].Text:='Files found: ' + IntToStr(ii);
       end;
   end;
 end;
end;
finally
 DirList.Free;
end;
end;
0
 
LVL 6

Author Comment

by:Dark_King
ID: 6246208
Hmm I miss that.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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