本文整理自网络,侵删。
function GetFileSize(const FileName : string): DWORD;var f : integer;begin f := FileOpen(FileName, fmOpenRead); try Result := Windows.GetFileSize(f, nil); finally FileClose(f); end; if Result = $FFFFFFFF then Result := 0;end; function CalcFileSizeStr(const Size : DWORD): string;const GB = 1024*1024*1024; MB = 1024*1024; KB = 1024;begin if Size > GB then Result := Format('%%.2f GB', [Size / GB]) else if Size > MB then Result := Format('%.2f MB', [Size / MB]) else if Size > KB then Result := Format('%.2f KB', [Size / KB]) else Result := Format('%d B', [Size]);end; function GetFileSizeStr(const FileName : string): string;var Size: DWORD;begin Size := GetFileSize(FileName); Result :=CalcFileSizeStr(Size);end; 相关阅读 >>
winapi 字符及字符串函数(6): ischaralphanumeric - 是否是个文字(字母或数字)
Delphi的idhttp报508 loop detected错误的原因
Delphi 将 html 代码直接加入到 twebbrowser 组件中去
更多相关阅读请进入《Delphi》频道 >>