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监控指定进程防止被关闭

Delphi 自动升级组件autoupgrader简单教程

Delphi如何删除数据库重复记录(4种方法)

Delphi 完美获取硬盘id

Delphi 最简单的升级下载代码

Delphi10.3.1安卓照相

Delphi 安卓获得设备 id

Delphi 带参数的 exit

Delphi 几个实用的html解析函数

Delphi 2009 之 tstringbuilder 类[1]: create

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



打赏

取消

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

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

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

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

评论

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