Open a new console application while running the existing console app) [duplicate]
Possible Duplicate:
Is there a way to create a second console to output to in .NET when writing a console application?
How to open a new console application (2) while running the existing console app (1)?
static void Main(strin开发者_运维百科g[] args)
{
try
{
Console.WriteLine("success");
//how to close this console
}
catch (Exception ex)
{
Console.WriteLine("Error Due To: " + ex.Message);
}
finally
{
//code for opening the second console....(is that passible)
//how to close this console
}
}
See Process
Class
System.Diagnostics.Process.Start()
Edit: Something like that, but you have to notice that this will create a new instance of the application every time the previous version closed! (is that what you want?)
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("success");
}
catch (Exception ex)
{
Console.WriteLine("Error Due To: " + ex.Message);
}
finally
{
//code for opening the second console....(is that passible)
System.Diagnostics.Process.Start("ConsoleApplication15.exe");
}
}
}
精彩评论