{"id":17197174,"url":"https://github.com/thomaslevesque/humanbytes","last_synced_at":"2025-04-13T19:51:31.699Z","repository":{"id":19529255,"uuid":"22776741","full_name":"thomaslevesque/HumanBytes","owner":"thomaslevesque","description":"A library to convert byte sizes to a human readable form","archived":false,"fork":false,"pushed_at":"2022-09-14T03:19:03.000Z","size":38,"stargazers_count":32,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T10:37:32.909Z","etag":null,"topics":["bytes","csharp","dotnet","human","size"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomaslevesque.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-09T02:11:56.000Z","updated_at":"2023-01-22T19:26:00.000Z","dependencies_parsed_at":"2023-01-11T20:29:41.428Z","dependency_job_id":null,"html_url":"https://github.com/thomaslevesque/HumanBytes","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FHumanBytes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FHumanBytes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FHumanBytes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomaslevesque%2FHumanBytes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomaslevesque","download_url":"https://codeload.github.com/thomaslevesque/HumanBytes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248773812,"owners_count":21159519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bytes","csharp","dotnet","human","size"],"created_at":"2024-10-15T01:55:39.333Z","updated_at":"2025-04-13T19:51:31.657Z","avatar_url":"https://github.com/thomaslevesque.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HumanBytes\n\n[![NuGet version](https://img.shields.io/nuget/v/HumanBytes.svg?logo=nuget)](https://www.nuget.org/packages/HumanBytes)\n[![AppVeyor build](https://img.shields.io/appveyor/ci/thomaslevesque/humanbytes.svg?logo=appveyor)](https://ci.appveyor.com/project/thomaslevesque/humanbytes)\n[![AppVeyor tests](https://img.shields.io/appveyor/tests/thomaslevesque/humanbytes.svg?logo=appveyor)](https://ci.appveyor.com/project/thomaslevesque/humanbytes/build/tests)\n\nA library to convert byte sizes to a human readable form.\n\n## Installation\n\nInstall the library via NuGet\n\n```\nPM\u003e Install-Package HumanBytes\n```\n\n## Basic usage\n\nThe `Bytes` extension method returns an object that has a human readable string representation:\n\n```csharp\nvar f = new FileInfo(\"TheFile.jpg\");\nConsole.WriteLine($\"The size of '{f.Name}' is {f.Length.Bytes()}\");\n// Prints \"The size of 'TheFile.jpg' is 89 KB\"\n```\n\nThe value is formatted using the default formatter; you can change the default formatter settings through the `ByteSizeFormatter.Default` static property.\n\n## More advanced usage\n\nIf you need more control, create an instance of `ByteSizeFormatter` and change its settings:\n\n```csharp\nvar formatter = new ByteSizeFormatter\n{\n    Convention = ByteSizeConvention.Binary,\n    DecimalPlaces = 1,\n    NumberFormat = \"#,##0.###\",\n    MinUnit = ByteSizeUnit.Kilobyte,\n    MaxUnit = ByteSizeUnit.Gigabyte,\n    RoundingRule = ByteSizeRounding.Closest,\n    UseFullWordForBytes = true,\n};\n\nvar f = new FileInfo(\"TheFile.jpg\");\nConsole.WriteLine($\"The size of '{f.Name}' is {formatter.Format(f.Length)}\");\n// Prints \"The size of 'TheFile.jpg' is 88.7 KiB\"\n```\n\n## Localization\n\nAt this stage, HumanBytes only supports English and French. However, if you need support for another language, it's very easy, as there are only 3 terms that need to be translated. Just create an instance of `ByteSizeFormatter` as shown above, and set the following properties:\n\n- `ByteSymbol`: the symbol for byte, e.g. \"B\" in English.\n- `ByteWord`: the word for byte, e.g. \"byte\" in English.\n- `BytesWord`: the word for several bytes, e.g. \"bytes\" in English.\n\nThe values set on these properties will be used instead of the ones defined in resources.\n\nIf you would like to add permanent support for another language, you'll have to modify the library itself. Just clone the project, add a `Resources.xx.resx` file (where `xx` is the language code) in the `HumanBytes/Properties` folder, translate the terms, and build.\n\nI'll be glad to accept pull requests to support more languages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaslevesque%2Fhumanbytes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomaslevesque%2Fhumanbytes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomaslevesque%2Fhumanbytes/lists"}