FileSizeToStr function
|
![]() ![]() ![]() |
acUtils
|
function FileSizeToStr(FileName: String;
|
[Bytes, Kb, Mb: String]): String;
|
The FileSizeToStr function returns the string representation of file size. You just need to point the FileName (file name with full path) and function will return the file size in bytes, kilobytes or megabytes (depending on actual size).
|
|
![]() |
|
The number of digits after decimal points depends on file size as well. There is no digits after dicimal point for size in bytes, 1 digit in value in kilobytes and 2 digits in value in megabytes.
|
|
For example, return value for file with size of 21090 bytes will be "20.5 KB". If file size is 3867291 bytes, the return value will be "3.68 MB".
|
|
![]() |
Default values is "bytes", "KB" and "MB".
|
1. FileSizeLabel.Caption := FileSizeToStr(FileName);
|
|
2. ListItem.Caption := ExtractFileName(FileName) + '( ' + FileSizeToStr(FileName, 'bytes', 'KB', 'MB') + ')';
|
|
3. ListItem.Caption := ExtractFileName(FileName) + '( ' + FileSizeToStr(FileName, 'bytes', 'kilobytes', 'megabytes') + ')';
|
ExtractFileSize function.
|