Mpdreamz / shellprogressbar

ShellProgressBar - display progress in your console application
MIT License
1.44k stars 134 forks source link

If output is redirected, disables progress bar and allows only taskbar progress display #44

Closed hakakou closed 5 years ago

hakakou commented 5 years ago

Under windows, If you try to redirect output using the > an error is thrown. This is probably the reason #35 occurs also.

c:\test.exe > out.txt

Unhandled Exception: System.IO.IOException: The handle is invalid.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.Console.set_CursorVisible(Boolean value)
   at ShellProgressBar.ProgressBar..ctor(Int32 maxTicks, String message, ProgressBarOptions options)

So with this fix, if output is found to be redirected, the progress bar is disabled and only progress on the taskbar is shown.

GF-Huang commented 4 years ago

Still occurs in VS Code .csx script file.

image