Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Error in findfirst file size

Avatar of eNarc
eNarcFlag for United Kingdom of Great Britain and Northern Ireland asked on
DelphiPascal
6 Comments1 Solution711 ViewsLast Modified:
Hi, I'm having problems with displaying the correct sum of files in a folder.

I've used

for some reason when I use the code below on a folder it brings back negative, even though the list that its adding is all positive.

I'm having trouble with both ways of getting the size.

is there a way of doing it so all files bring back the true size?
 
function Search(path:string;o:integer):string;
var
  sr : tsearchrec;
  res: integer;
  i  :integer;
  z:int64;
begin
  path:= includetrailingpathdelimiter(path);
  res:= findfirst(path+'*.*',faAnyfile,sr);
  while res = 0 do begin
    application.processmessages;
    if (sr.name <> '.') and (sr.name <> '..') then
      if DirectoryExists(path + sr.name) then begin


        Form32.Richedit1.lines.add('Folders: '+path+sr.name);
        Search(path + sr.name,o);
      end else begin

    //z:=Int64(sr.FindData.nFileSizeHigh) shl Int64(32) + Int64(sr.FindData.nFileSizeLow)+z;
      z:=Sr.Size;

        Filesizes:=Filesizes+z;

        Form32.Richedit1.lines.add('Files: '+path+sr.name);
      end;

    res := findnext(sr);
  end;
  findclose(sr);

end;
ASKER CERTIFIED SOLUTION
Avatar of Emmanuel PASQUIER
Emmanuel PASQUIERFlag of France imageFreelance Project Manager
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answers