How do I get a human-readable file size in bytes abbreviation using .NET?

This may not the most efficient or optimized way to do it, but it’s easier to read if you are not familiar with log maths, and should be fast enough for most scenarios. string[] sizes = { “B”, “KB”, “MB”, “GB”, “TB” }; double len = new FileInfo(filename).Length; int order = 0; while (len >= … Read more

Find size of Git repository

Note that, since git 1.8.3 (April, 22d 2013): “git count-objects” learned “–human-readable” aka “-H” option to show various large numbers in Ki/Mi/GiB scaled as necessary. That could be combined with the -v option mentioned by Jack Morrison in his answer. git gc git count-objects -vH (git gc is important, as mentioned by A-B-B’s answer) Plus … Read more