I have a value stored in a variable which is of type “long”.
long fileSizeInBytes = FileUploadControl.FileContent.Length;
Decimal fileSizeInMB = Convert.ToDecimal(fileSizeInBytes / (1024 * 1024));
I want to convert the fileSizeInBytes to decimal number rounded up to 2 decimal places (like these: 1.74, 2.45, 3.51) But i’m not able to get the required result. I’m only getting single digit with no decimal places as result. Can some one help me with that ??.
Thanks in anticipation
What you’re doing is dividing the filesize by an integer, which results in an integer, not a decimal. Any remainder left over will be chopped off.