SquirrelSizer 2.0.0

dotnet add package SquirrelSizer --version 2.0.0
NuGet\Install-Package SquirrelSizer -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SquirrelSizer" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SquirrelSizer --version 2.0.0
#r "nuget: SquirrelSizer, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SquirrelSizer as a Cake Addin
#addin nuget:?package=SquirrelSizer&version=2.0.0

// Install SquirrelSizer as a Cake Tool
#tool nuget:?package=SquirrelSizer&version=2.0.0

Squirrel-Sizer

This is a simple file sizing library.

Goto https://www.nuget.org/packages/SquirrelSizer/

To use it is simple.

You give it a long number and it gives you a string with the size abbreviation suffix.

long number = 1234500;
Sizer.Suffix(number); 
// This will output 1kb

or

long number = 1234500;
Sizer.SuffixName(number); 
// This will output 1 Kilobyte

It will always give you a number with your string

To stop it from giving you a number

long number = 1234500;
Sizer.Suffix(number, includeNumber: false)
// This will output kb

You have to include the "includeNumber:" part, this is cause of the way I implemented it.

I might change this later.


To change how many decimal places to use it's easy as well

long number = 1234500;
Sizer.SuffixName(number, 4)
// This will output 1.1773 Kilobyte
long number = 1234500;
Sizer.SuffixName(number, 4, false)
// This will output Kilobyte

To use this with files is even as easy.

Sizer.Suffix("C:\\Path\\To\\File\\file.txt"); 
// This will output the converted size of the file.

or

Sizer.SuffixName("C:\\Path\\To\\File\\file.txt"); 
// This will output the converted size of the file.

You can even get the complete size of multiple files

List<string> files = new List<string>() {
            "C:\\Path\\To\\File\\file1.txt",
            "C:\\Path\\To\\File\\file2.txt",
            "C:\\Path\\To\\File\\file3.txt"
        };
Sizer.AllSuffix(files); 
// This will output the size of all the files in the list

or

List<string> files = new List<string>() {
            "C:\\Path\\To\\File\\file1.txt",
            "C:\\Path\\To\\File\\file2.txt",
            "C:\\Path\\To\\File\\file3.txt"
        };
Sizer.AllSuffixName(files); 
// This will output the size of all the files in the list

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.0 349 9/3/2023
1.2.0 835 7/7/2020
1.1.0 733 7/6/2020
1.0.2 823 2/17/2020