1
Vote

ByteConverter doesn't work correctly

description

Hi, Guys.
I am using your component in sharepoint portal and it's great. I am very thankfull to you.
 
But I found some defect, please review it:
 
Please add double cast for byteCount because default cast for this step is integer and user can't see float part of byteCount.
 
Correct code:
 
(double) byteCount / ...
 
            if (byteCount >= 1073741824)
                size = String.Format("{0:##.##}", (double) byteCount / 1073741824) + " GB";
            else if (byteCount >= 1048576)
                size = String.Format("{0:##.##}", (double) byteCount / 1048576) + " MB";
            else if (byteCount >= 1024)
                size = String.Format("{0:##.##}", (double) byteCount / 1024) + " KB";
            else if (byteCount > 0 && byteCount < 1024)
                size = "1 KB";    //Bytes are unimportant ;)            
 
With The Best Regards,
Alexander

comments