How to format a file size with separate values?

How to format a string that includes the size in bytes of files, separating the thousands, millions, billions, with a space (like the Finder).
expected result: 123456789000 bytes >> 123 456 789 000 bytes.
I tried this without success:

Label1.Text = format(file.Length, "#,##0") + " bytes "  
1 Like

You can do it that way:
MessageBox Format(123456789,“###\ ###\ ###\ ###\ ###\ ###\ ###\ ###”)

(the fact of using # makes it possible to have many more # than required, in case your number would be higher than expected, without cluttering with zeros)

What do you get?


= i.ToString("###,##0") + " bytes "

should give you spaces or commas depending on your locale. You can force an output if you define a locale and use

= i.ToString(myLocale,"###,##0") + " bytes "