delphi如何计算一个文件目录的大小


本文整理自网络,侵删。

 delphi如何计算一个目录的大小

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;

相关阅读 >>

Delphi:取得浏览器地址,网址(支持ie,firefox)

Delphi 结束360safe和360保险箱进程

Delphi 2009 之 tstringbuilder 类[5]: chars[] 属性与 copyto 方法

Delphi工具之tdump

Delphi 写一个可拖动的 tshape

Delphi文件是否正在使用

Delphi combobox 下拉事件

Delphi读写二进制文件

Delphi 快速读取txt 指定行的数据

Delphi 使控件支持鼠标滚轴消息

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...