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中inputbox 和inputquery 函数的使用

winapi 字符及字符串函数(11): lstrcpyn - 复制字符串, 同时指定要复制的长度

Delphi trayicon1 托盘气泡提示

Delphi直接实现分享图片功能

Delphi开发的服务中调用指定应用程序

Delphi编程之关闭所有qq进程

Delphi 分割字符串 extractstrings

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

Delphi hexstrtostream

Delphi 获取标题栏高

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



打赏

取消

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

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

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

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

评论

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