急用:+一起帮小弟我调试一下:怎么获得指定目录大小(有源码)
急用:在线等+一起帮我调试一下:如何获得指定目录大小(有源码)
有更好的方法请指教
function GetDirectorySize(const ADirectory: string): Integer;
var
Dir: TSearchRec;
Ret: integer;
Path: string;
begin
Result := 0;
// Path := ExtractFilePath(ADirectory);
Ret := Sysutils.FindFirst(ADirectory, faAnyFile, Dir);
// if Ret <> NO_ERROR then exit;
try
while ret <> NO_ERROR do begin
inc(Result, Dir.Size);
if (Dir.Attr in [faDirectory]) and (Dir.Name[1] <> '. ') then
Inc(Result, GetDirectorySize(Path + Dir.Name + '\*.* '));
Ret := Sysutils.FindNext(Dir);
end;
finally
Sysutils.FindClose(Dir);
end;
end;
------解决方案--------------------
你这个递归根本就没有出口
有更好的方法请指教
function GetDirectorySize(const ADirectory: string): Integer;
var
Dir: TSearchRec;
Ret: integer;
Path: string;
begin
Result := 0;
// Path := ExtractFilePath(ADirectory);
Ret := Sysutils.FindFirst(ADirectory, faAnyFile, Dir);
// if Ret <> NO_ERROR then exit;
try
while ret <> NO_ERROR do begin
inc(Result, Dir.Size);
if (Dir.Attr in [faDirectory]) and (Dir.Name[1] <> '. ') then
Inc(Result, GetDirectorySize(Path + Dir.Name + '\*.* '));
Ret := Sysutils.FindNext(Dir);
end;
finally
Sysutils.FindClose(Dir);
end;
end;
------解决方案--------------------
你这个递归根本就没有出口