Skulle detta fungera?
static string GetBytes(double bytes) {
string result;
try {
if(bytes >= (1024*1024*1024)) {
result = string.Format("{0:#.##} GB",bytes/(1024*1024*1024));
} else if (bytes >= (1024*1024)) {
result = string.Format("{0:#.##} MB",bytes/(1024*1024));
} else if (bytes >= (1024)) {
result = string.Format("{0:#.##} KB",bytes/(1024));
} else {
result = string.Format("{0:#.##} B",bytes);
}
} catch(Exception ex) {
result = ex.Message;
}
return result;
}
Mvh
JohanL
