BuildReportTool.Util.MyFileSizeReadable C# (CSharp) Method

MyFileSizeReadable() static private method

static private MyFileSizeReadable ( double bytes ) : string
bytes double
return string
	static string MyFileSizeReadable(double bytes)
	{

		double converted = bytes;
		string units = "B";

		if (bytes >= ONE_TERABYTE)
		{
			converted = bytes / ONE_TERABYTE;
			units = "TB";
		}
		else if (bytes >= ONE_GIGABYTE)
		{
			converted = bytes / ONE_GIGABYTE;
			units = "GB";
		}
		else if (bytes >= ONE_MEGABYTE)
		{
			converted = bytes / ONE_MEGABYTE;
			units = "MB";
		}
		else if (bytes >= ONE_KILOBYTE)
		{
			converted = bytes / ONE_KILOBYTE;
			units = "KB";
		}

		return String.Format("{0:0.##} {1}", converted, units);
	}