Skip to content

Commit

Permalink
- Fix #49
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaBear84 committed Nov 29, 2020
1 parent abf93bf commit 746dc1b
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions OpenDirectoryDownloader/Library.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,22 @@ private static SpeedtestResult SpeedtestFromStream(Stream stream, int seconds)

private static void ClearCurrentLine()
{
do { Console.Write("\b \b"); } while (Console.CursorLeft > 0);
try
{
if (!Console.IsOutputRedirected)
{
Console.Write(new string('+', Console.WindowWidth).Replace("+", "\b \b"));
}
else
{
Console.WriteLine();
}
}
catch
{
// Happens when console is redirected, and just to be sure
Console.WriteLine();
}
}

private static Uri GetUrlDirectory(string url)
Expand All @@ -258,7 +273,7 @@ public static DateTime UnixTimestampToDateTime(long unixTimeStamp)
public static Stream GetEmbeddedResourceStream(Assembly assembly, string resourceFileName)
{
List<string> resourcePaths = assembly.GetManifestResourceNames().Where(x => x.EndsWith(resourceFileName, StringComparison.OrdinalIgnoreCase)).ToList();

if (resourcePaths.Count == 1)
{
return assembly.GetManifestResourceStream(resourcePaths.Single());
Expand Down

0 comments on commit 746dc1b

Please sign in to comment.