Tuesday, 7 October 2014

How to write to console from Windows Application



When creating a Windows Applicaiton, either WinForms or WPF it does not have console. Converting the application to Console Application seems to solve the problem. If we execute our application from a console, it will be able to print to console and everything seems to be fine. But when we run it not from a console  a new console window will appear in addition to the existing Form or WPF Window. So what we can do?



AttachToConsole will actually attach to the parent console from which the Windows Application was executed. Unfortunately, it does not move the cursor to the next line. Thus the next line is required Console.Writeline.



Post a Comment