diff --git a/Correlator.sln b/Correlator.sln index ea97844..84d78e1 100644 --- a/Correlator.sln +++ b/Correlator.sln @@ -8,19 +8,13 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Debug|x64.ActiveCfg = Debug|x64 - {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Debug|x64.Build.0 = Debug|x64 {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.Build.0 = Release|Any CPU - {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.ActiveCfg = Release|x64 - {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Correlator.sln b/Correlator.sln index ea97844..84d78e1 100644 --- a/Correlator.sln +++ b/Correlator.sln @@ -8,19 +8,13 @@ Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Debug|x64.ActiveCfg = Debug|x64 - {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Debug|x64.Build.0 = Debug|x64 {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|Any CPU.Build.0 = Release|Any CPU - {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.ActiveCfg = Release|x64 - {BD4834CC-8FE1-47B4-BF30-982CD23CBC7F}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Correlator/Util/MethodExtensions.cs b/Correlator/Util/MethodExtensions.cs index 72fa7c3..50138c5 100644 --- a/Correlator/Util/MethodExtensions.cs +++ b/Correlator/Util/MethodExtensions.cs @@ -32,33 +32,12 @@ /// /// 计算文件占用空间大小 /// - /// + /// /// - public static string FormatFileSize(this long size) + public static string FormatFileSize(this long length) { - string fileSize; - if (size == 0) - { - fileSize = "0B"; - } - else if (size < 1024) - { - fileSize = $"{size:#.0}" + "B"; - } - else if (size < 1048576) - { - fileSize = $"{(double)size / 1024:#.0}" + "K"; - } - else if (size < 1073741824) - { - fileSize = $"{(double)size / 1048576:#.0}" + "M"; - } - else - { - fileSize = $"{(double)size / 1073741824:#.0}" + "G"; - } - - return fileSize; + var size = (double)length / (1024 * 1024); + return $"{size:F2}MB"; } ///