You are correct, you probably have come across this. The Sitecore.StringUtil, Sitecore.Kernel
class contains a number of methods for managing strings.
The two methods in particular are:
StringUtil.GetSizeString(long size)
This method takes in a long value 524288000, and returns a string representation of "512MB"
StringUtil.ParseSizeString(string value)
This method takes in a string value like "512MB" and returns the long representation of that size, 524288000.
An Example:
using Sitecore;
public long GetLongValue(string valueSize)
{
return StringUtil.ParseSizeString(valueSize);
}
public string GetStringSize(long size)
{
return StringUtil.GetSizeString(size);
}