From a21f35bea2692be983a2697eeb44456b953b9066 Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Fri, 22 Mar 2019 23:02:35 +0100 Subject: [PATCH] Initial --- Mk0.Tools.Calculation.sln | 25 ++++++++++++ Mk0.Tools.Calculation/FileSize.cs | 25 ++++++++++++ .../Mk0.Tools.Calculation.csproj | 38 +++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++++++++++++++ README.md | 7 +++- 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 Mk0.Tools.Calculation.sln create mode 100644 Mk0.Tools.Calculation/FileSize.cs create mode 100644 Mk0.Tools.Calculation/Mk0.Tools.Calculation.csproj create mode 100644 Mk0.Tools.Calculation/Properties/AssemblyInfo.cs diff --git a/Mk0.Tools.Calculation.sln b/Mk0.Tools.Calculation.sln new file mode 100644 index 0000000..fe767a8 --- /dev/null +++ b/Mk0.Tools.Calculation.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.438 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mk0.Tools.Calculation", "Mk0.Tools.Calculation\Mk0.Tools.Calculation.csproj", "{C52446DD-91BE-4071-BB4E-C46860D2EF98}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C52446DD-91BE-4071-BB4E-C46860D2EF98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C52446DD-91BE-4071-BB4E-C46860D2EF98}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C52446DD-91BE-4071-BB4E-C46860D2EF98}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C52446DD-91BE-4071-BB4E-C46860D2EF98}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C0C0BF4C-DA68-4968-A459-89D2FDC6D7ED} + EndGlobalSection +EndGlobal diff --git a/Mk0.Tools.Calculation/FileSize.cs b/Mk0.Tools.Calculation/FileSize.cs new file mode 100644 index 0000000..7fd0016 --- /dev/null +++ b/Mk0.Tools.Calculation/FileSize.cs @@ -0,0 +1,25 @@ +namespace Mk0.Tools.Calculation +{ + public class FileSize + { + /// + /// Dateigröße in B,KB,MB,TB + /// + /// Dateigröße in Bytes + /// Dateigröße in lesbarem Format mit Zusatz (KB, MB...) + public static string GetFileSize(double byteCount) + { + string size = "0 Bytes"; + if (byteCount >= 1073741824.0) + size = string.Format("{0:##.##}", byteCount / 1073741824.0) + " GB"; + else if (byteCount >= 1048576.0) + size = string.Format("{0:##.##}", byteCount / 1048576.0) + " MB"; + else if (byteCount >= 1024.0) + size = string.Format("{0:##.##}", byteCount / 1024.0) + " KB"; + else if (byteCount > 0 && byteCount < 1024.0) + size = byteCount.ToString() + " Bytes"; + + return size; + } + } +} diff --git a/Mk0.Tools.Calculation/Mk0.Tools.Calculation.csproj b/Mk0.Tools.Calculation/Mk0.Tools.Calculation.csproj new file mode 100644 index 0000000..3f7de0f --- /dev/null +++ b/Mk0.Tools.Calculation/Mk0.Tools.Calculation.csproj @@ -0,0 +1,38 @@ + + + + + Debug + AnyCPU + {C52446DD-91BE-4071-BB4E-C46860D2EF98} + Library + Properties + Mk0.Tools.Calculation + Mk0.Tools.Calculation + v4.6.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + \ No newline at end of file diff --git a/Mk0.Tools.Calculation/Properties/AssemblyInfo.cs b/Mk0.Tools.Calculation/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..50369fc --- /dev/null +++ b/Mk0.Tools.Calculation/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("Mk0.Tools.Calculation")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Mk0.Tools.Calculation")] +[assembly: AssemblyCopyright("Copyright © 2019 mk0.at")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("c52446dd-91be-4071-bb4e-c46860d2ef98")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// indem Sie "*" wie unten gezeigt eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/README.md b/README.md index d7313ea..8ebb87d 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -# Mk0.Tools.Calculation \ No newline at end of file +# Mk0.Tools.Calculation +(C) 2019 mk0.at + +Allows the following operations + ++ GetFileSize - input bytes and recieve f.e. "20,5 MB" \ No newline at end of file