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-idhttp-json用法

Delphi 动态修改显示器分辨率

Delphi tgauge类的定义在哪个单元中定义的?

Delphi winapi: messagebeep - 播放一个系统声音

Delphi strtohexstr 字符串转换hex

Delphi 如何识别应用程序没有响应

Delphi xe的firemonkey获取当前文件所在路径的方法

Delphi二值图像除杂点(噪点)

Delphi trim 删除字符串左右两边的空格

Delphi xe6、xe5、xe7在android创建快捷方式

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



打赏

取消

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

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

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

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

评论

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