AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

TSearchRec with progressbar

Ein Thema von sdean · begonnen am 5. Mär 2010 · letzter Beitrag vom 9. Mär 2010
Antwort Antwort
sdean

Registriert seit: 5. Dez 2009
64 Beiträge
 
#1

TSearchRec with progressbar

  Alt 5. Mär 2010, 21:04
I've this procedure to search for files , But what i want to add is the progressbar feature; the progressbar will move along with procedure .

Delphi-Quellcode:
procedure TfrMain.FileSearch(const PathName, FileName : string; const InDir : boolean);
var Rec : TSearchRec;
    Path : string;
begin
Path := IncludeTrailingBackslash(PathName);
if FindFirst(Path + FileName, faAnyFile - faDirectory, Rec) = 0 then
 try
   repeat
     ListBox1.Items.Add(Path + Rec.Name);
   until FindNext(Rec) <> 0;
 finally
   FindClose(Rec);
 end;

If not InDir then Exit;

if FindFirst(Path + '*.*', faDirectory, Rec) = 0 then
 try
   repeat
    if ((Rec.Attr and faDirectory) <> 0) and (Rec.Name<>'.') and (Rec.Name<>'..') then
     FileSearch(Path + Rec.Name, FileName, True);
   until FindNext(Rec) <> 0;
 finally
   FindClose(Rec);
 end;
end; //procedure FileSearch
  Mit Zitat antworten Zitat
Benutzerbild von chaosben
chaosben

Registriert seit: 27. Apr 2005
Ort: Görlitz
1.358 Beiträge
 
Delphi XE2 Professional
 
#2

Re: TSearchRec with progressbar

  Alt 6. Mär 2010, 06:05
There is no way to implement a real progress (take a look at the second post, for fake progress), without having an index.
Of course, you may count the files in a first run and use this number in a second run to calculate the progress. But this makes no sense.
Benjamin Schwarze
If I have seen further it is by standing on the shoulders of Giants. (Isaac Newton)
  Mit Zitat antworten Zitat
hoika

Registriert seit: 5. Jul 2006
Ort: Magdeburg
8.270 Beiträge
 
Delphi 10.4 Sydney
 
#3

Re: TSearchRec with progressbar

  Alt 6. Mär 2010, 07:02
Hello,

You can use the ProgressBar to show,
that there is something in progress,
so if you are at ProgressBar.Max,
restart with 1.

This is similiar with Explorer-Copy in Win7.


Heiko
Heiko
  Mit Zitat antworten Zitat
Benutzerbild von xZise
xZise

Registriert seit: 3. Mär 2006
Ort: Waldbronn
4.303 Beiträge
 
Delphi 2009 Professional
 
#4

Re: TSearchRec with progressbar

  Alt 9. Mär 2010, 10:33
Moin,
And in newer versions of Delphi you can use a Marqueebar, so the user can see, that there is working something.

You can't the the number of files within a directory, without counting them in a separated TSearchRec loop (but then you would do everything twice). This way is only suitable, when you do big thinks with every file, so the counting is very fast compared to the calculation.

Sincerly
Fabian

PS: Sorry for my english
Fabian
Eigentlich hat MS Windows ab Vista den Hang zur Selbstzerstörung abgewöhnt – mkinzler
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:34 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz