S
SUNSTONE的Delphi笔记
Unregistered / Unconfirmed
GUEST, unregistred user!
经常用到把字节数显示成kb或gb,函数如下
function FormatByteSize(const bytes: Longint): string;
const
B = 1; //byte
KB = 1024 * B; //kilobyte
MB = 1024 * KB; //megabyte
GB = 1024 * MB; //gigabyte
begin
if bytes > GB then
result := FormatFloat('#.## GB', bytes / GB)
else
if bytes > MB then
result := FormatFloat('#.## MB', bytes / MB)
else
if bytes > KB then
result := FormatFloat('#.## KB', bytes / KB)
else
result := FormatFloat('#.## bytes', bytes) ;
end;
作者:sunstone 发表于 2010/12/22 13:31:00 原文链接 https://blog.csdn.net/sunstone/article/details/6091520
阅读:1480
查看更多...
function FormatByteSize(const bytes: Longint): string;
const
B = 1; //byte
KB = 1024 * B; //kilobyte
MB = 1024 * KB; //megabyte
GB = 1024 * MB; //gigabyte
begin
if bytes > GB then
result := FormatFloat('#.## GB', bytes / GB)
else
if bytes > MB then
result := FormatFloat('#.## MB', bytes / MB)
else
if bytes > KB then
result := FormatFloat('#.## KB', bytes / KB)
else
result := FormatFloat('#.## bytes', bytes) ;
end;
作者:sunstone 发表于 2010/12/22 13:31:00 原文链接 https://blog.csdn.net/sunstone/article/details/6091520
阅读:1480
查看更多...