Take the 2-minute tour ×  I'm using the code below to convert
the file size in bytes (test file is 31718 bytes) to KB
(30.974609375 KB) but I want to display this to one decimal
place (i.e. 30.9 KB). How would I do this in VB.NET?  New
FileInfo(FileName).Length / 1024   share|improve this question
Your number of 30.974609375 you have stated you would like this
to be 30.9. Is this correct? Are you sure you do not what this
to round to 31.0? 30.9123456 would round to 30.9 –  Robin Day
Apr 17 '09 at 11:42 add comment  3 Answers  up vote 7 down vote
accepted Math.Round(New FileInfo(FileName).Length / 1024,1)
share|improve this answer How can that be? In your example you
gave these facts, size = 31718, divided by 1024 = 30.974609375,
desired output = 30.9. The answer you said was perfect gives
31.0. –  dbasnett Apr 18 '09 at 13:30 He was wrong about the
30.9. Rounding 30.97 will always round up, if it was 30.94 or
less it would round down to 30.9. –  Mladen Mihajlovic Apr 18
'09 at 13:46 But I'm sure he was just u