Bytes to file size (Views: 28)
Problem/Question/Abstract: How I can convert bytes to file size in KB/MB like in windows explorer Answer: function FileSizeStr(Size: LongInt): string; begin if Size < 1000 then Result := IntToStr(Size) + ' B' else if Size < 102400 then Result := IntToStr((Size + 1023) shr 10) + ' KB' else Result := IntToStr((Size + 1048575) shr 20) + ' MB'; end; |