How do I parse the size of a file from like 1024 to 1kb?
once I created a function for it which was like 30 lines long full of if’s.
is there a more ‘elegant’ way to do it?
and what do I need to use?
1kb = 1000b or 1kb = 1024b?
How do I parse the size of a file from like 1024 to 1kb?
Share
This solution doesn’t look unreasonable. It’s a little long, but it does cater for exa/petabytes!
C# Human-Readable File Size Function
Sample Usage
It is recommended to put the above function in a helper or utility class as a public static method.