CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Tuesday, October 03, 2006

Function to convert Memory Size from Double To String in .NET

Function to convert Memory Size from Double To String in .NET
private string FormatSize(double fileSize)
{
if (fileSize < 1024)
return String.Format("{0:N0} B", fileSize);
else if (fileSize < 1024 * 1024)
return String.Format("{0:N2} KB", fileSize / 1024);
else
return String.Format("{0:N2} MB", fileSize / (1024 * 1024));
}

Post a Comment