diff --git a/src/OpenDirectoryDownloader/Helpers/FileSizeHelper.cs b/src/OpenDirectoryDownloader/Helpers/FileSizeHelper.cs index c5c35dd8..12978d97 100644 --- a/src/OpenDirectoryDownloader/Helpers/FileSizeHelper.cs +++ b/src/OpenDirectoryDownloader/Helpers/FileSizeHelper.cs @@ -120,12 +120,17 @@ public static long ParseFileSize(string value, int kbValue = 1024, bool throwExc private static readonly string[] sizeSuffixes = { "B", "kiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB" }; private static readonly string[] sizeSuffixesBit = { "b", "kib", "Mib", "Gib", "Tib", "Pib", "Eib", "Zib", "Yib" }; - public static string ToHumanReadable(long size, bool useBits = false) + public static string ToHumanReadable(long? size, bool useBits = false) { Debug.Assert(sizeSuffixes.Length > 0); const string formatTemplate = "{0}{1:#.##} {2}"; + if (size == null) + { + return "-"; + } + if (size == 0) { return string.Format(formatTemplate, null, 0, sizeSuffixes[0]);