Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string ToKMGTByte(ulong bytes)
- {
- var suffix = new[] { "B", "KB", "MB", "GB", "TB","PB" };
- int idx = 0;
- ulong rtn=bytes;
- while (idx<suffix.Length-1 && (bytes >>= 10) > 0)
- {
- rtn = bytes;
- idx++;
- }
- return string.Concat(rtn, suffix[idx]);
- }
- public static string ConvertToReadbleFileSize(long size)
- {
- return size > 1000000 ?
- (Math.Round((double)(size / (1024 * 1024)), 2)).ToString("0.00 GB") :
- (Math.Round((double)(size / 1024), 2)).ToString("0.00 MB");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement