Hello all,
I have a function within a thread that counts recursively the number of files there are within a given directory or directories and its subdirs. These directories are stored inside a TStringList, and I have a for-loop that iterates through the list, counting the number of files within them. This works fine.
My problem is that every time I add a new directory to the list, the for-loop iterates throughout the entire thing. From the first dir to the last dir. This can be really time-consuming considering I am counting thousands of files within each directory.
What I really want it to do is to not re-count the old directories that were already counted, but instead count the newly added directories and increment that total to the total amount.
I am using a really simple approach:
My search algorithm uses FindFirst and FindNext if that helps any.
Thanks
I have a function within a thread that counts recursively the number of files there are within a given directory or directories and its subdirs. These directories are stored inside a TStringList, and I have a for-loop that iterates through the list, counting the number of files within them. This works fine.
My problem is that every time I add a new directory to the list, the for-loop iterates throughout the entire thing. From the first dir to the last dir. This can be really time-consuming considering I am counting thousands of files within each directory.
What I really want it to do is to not re-count the old directories that were already counted, but instead count the newly added directories and increment that total to the total amount.
I am using a really simple approach:
Code:
I : Integer;
r, RN : Int64;
root : String;
ROOTS : TStringList;
RN := 0;
r := 0;
for I := 0 to ROOTS.Count - 1 do
begin
root := ROOTS[I];
RN := FindFiles(root, '*.*', True);
r := r + RN;
end;
lblSharedTotal.Caption := IntToStr(r) + ' Files Shared';
My search algorithm uses FindFirst and FindNext if that helps any.
Thanks