Created
February 11, 2022 14:32
-
-
Save t3knoid/f49de1d5cde1cc042003d88aa49474a3 to your computer and use it in GitHub Desktop.
Revisions
-
t3knoid created this gist
Feb 11, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ # Copied from https://www.codeproject.com/Tips/5255878/A-Console-Progress-Bar-in-Csharp using System; namespace CU { static class ConsoleUtility { const char _block = '■'; const string _back = "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"; const string _twirl = "-\\|/"; public static void WriteProgressBar(int percent, bool update = false) { if(update) Console.Write(_back); Console.Write("["); var p = (int)((percent / 10f)+.5f); for (var i = 0;i<10;++i) { if (i >= p) Console.Write(' '); else Console.Write(_block); } Console.Write("] {0,3:##0}%", percent); } public static void WriteProgress(int progress, bool update = false) { if (update) Console.Write("\b"); Console.Write(_twirl[progress % _twirl.Length]); } } }