Format filesize in kB or MB

A

Arjen

Hello,

When I have read a file with x.xxx.xxx.xxx bytes it is sometimes handy to
show it in an diverent format than bytes.

Is there a handy way to do this?
Or is there a function for it?

When it is a big file I want to see a MB size and when it is a lower file
size then I want to see a kB size for example.

Thanks!
 
E

eruess

It shouldn't be too much trouble to do it by hand, right? Like what about
this psuedo code:

select case filesize
case >= 1,000,000,000,000
(display) filesize \ 1,000,000,000,000 & " TB?"
case >= 1,000,000,000
(display) filesize \ 1,000,000,000 & " GB"
case >= 1,000,000
(display) filesize \ 1,000,000 & " MB"
case >= 1,000
(display) filesize \ 1,000 & " KB"
case else
(display) filesize & " bytes"
end select
 
J

Jerry III

Actually Windows API provides such a function,
StrFormatByteSizeA/StrFormatByteSizeW. If you really wanted to you could use
that (through a COM object?).

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top