Skip to content

Instantly share code, notes, and snippets.

@Marzogh
Created August 28, 2015 00:48
Show Gist options
  • Save Marzogh/4f89a0a21d83c0a9e616 to your computer and use it in GitHub Desktop.
Save Marzogh/4f89a0a21d83c0a9e616 to your computer and use it in GitHub Desktop.
Easy format to use while converting between different storage sizes
knownUnits = new Dictionary<string, long>
{
{ "", 1L }, // no unit is same as unit B(yte)
{ "B", 1L },
{ "KB", 1024L },
{ "MB", 1024L * 1024L},
{ "GB", 1024L * 1024L * 1024L},
{ "TB", 1024L * 1024L * 1024L * 1024L}
// fill rest as needed
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment