How to return KB, MB and GB from Bytes using a public function
问题 I'm writing a "function" that returns a file's size (in B, KB, MB, GB). The VB.Net code always gets the size in bytes first, so when a file's size (in Bytes) is less than 100 it returns B, if its > 1000 then I divide it by 1000 and it returns KB. But when it should be MB I try dividing by 1000000 and the size it returns always comes out 2 MBs bigger than what it should be!? Can someone please tell me what I'm doing wrong!! Example My files size is (15,570,550 Bytes) ..which is.. (14.8 MB) So