https://github.com/mrsquirrely/squirrel-sizer
A simple and easy to use file sizing utility
https://github.com/mrsquirrely/squirrel-sizer
csharp dotnet-standard file-sizer filesize simple
Last synced: 10 months ago
JSON representation
A simple and easy to use file sizing utility
- Host: GitHub
- URL: https://github.com/mrsquirrely/squirrel-sizer
- Owner: MrSquirrely
- License: lgpl-3.0
- Created: 2019-07-03T21:03:38.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-09-03T13:03:05.000Z (almost 3 years ago)
- Last Synced: 2025-08-01T01:24:17.994Z (11 months ago)
- Topics: csharp, dotnet-standard, file-sizer, filesize, simple
- Language: C#
- Homepage:
- Size: 32.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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.
```c#
long number = 1234500;
Sizer.Suffix(number);
// This will output 1kb
```
or
```c#
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
```c#
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
```c#
long number = 1234500;
Sizer.SuffixName(number, 4)
// This will output 1.1773 Kilobyte
```
```c#
long number = 1234500;
Sizer.SuffixName(number, 4, false)
// This will output Kilobyte
```
-------
### To use this with files is even as easy.
```c#
Sizer.Suffix("C:\\Path\\To\\File\\file.txt");
// This will output the converted size of the file.
```
or
```c#
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
```c#
List files = new List() {
"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
```c#
List files = new List() {
"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
```
-------