Opening console app using C# code in win forms -
i trying open console application windows forms application. have used below code. code opening console application not displaying (showing black screen). able console output using standardoutput.
process proc = new process(); proc.startinfo.createnowindow = false; proc.startinfo.useshellexecute = false; proc.startinfo.redirectstandardoutput = true; proc.startinfo.redirectstandarderror = true; proc.startinfo.redirectstandardinput = true; proc.startinfo.filename = @"c:\program filex86)\consoletool.exe"; proc.start(); streamwriter sw = proc.standardinput; sw.writeline("init"); txtoutput.text += proc.standardoutput.readtoend().replace("\n", "\r\n"); txtoutput.text += proc.standarderror.readtoend().replace("\n", "\r\n"); proc.waitforexit();
how display on console window opened using code?
use allocconsole
function open console window , use console.writeline
or other console functions normally!
example:
[system.runtime.interopservices.dllimport("kernel32")] extern static void allocconsole(); //.... allocconsole(); console.writeline("hello world"); console.readkey();
Comments
Post a Comment