Kullanıcı menü seçeneğini seçtiğinde konsolu kapatmalıyım.Konsolun bir uygulamasını kapatmak için komut?
Ben close()
kullanarak denedim ama işe yaramadı ..
bunu nasıl yapabilirim?
Kullanıcı menü seçeneğini seçtiğinde konsolu kapatmalıyım.Konsolun bir uygulamasını kapatmak için komut?
Ben close()
kullanarak denedim ama işe yaramadı ..
bunu nasıl yapabilirim?
Environment.Exit
ve Application.Exit
Environment.Exit(0)
temizleyicidir. yakın By
http://geekswithblogs.net/mtreadwell/archive/2004/06/06/6123.aspx
, size kapatmak için konsol uygulamanın mevcut örneğini istediğim anlamına yaparsın, ya da sonlandırmak için, başvuru sürecini istiyorsun?
Environment.Exit(0);
Veya formun geçerli örneğini kapatmak için: tüm önemli çıkış kodu olduğunu Kaçırılan
this.Close();
Faydalı link.
Bu
Application.Exit();
//How to start another application from the current application
Process runProg = new Process();
runProg.StartInfo.FileName = pathToFile; //the path of the application
runProg.StartInfo.Arguments = genArgs; //any arguments you want to pass
runProg.StartInfo.CreateNoWindow = true;
runProg.Start();
//How to end the same application from the current application
int IDstring = System.Convert.ToInt32(runProg.Id.ToString());
Process tempProc = Process.GetProcessById(IDstring);
tempProc.CloseMainWindow();
tempProc.WaitForExit();
Dolayısıyla, başka bir seçenek olarak bu yüzden, belki de sadece tepki döngü zarif dışarı sona sahip, aniden çıkmak veya çıkılması uygulamayı istediği demedi deneyin olabilir. (Kullanıcı talimatlarını beklemek için bir süre geçmişiniz olduğunu varsayardım. Bu, bugün yazdığım bir projeden bazı kodlar.
Console.WriteLine("College File Processor");
Console.WriteLine("*************************************");
Console.WriteLine("(H)elp");
Console.WriteLine("Process (W)orkouts");
Console.WriteLine("Process (I)nterviews");
Console.WriteLine("Process (P)ro Days");
Console.WriteLine("(S)tart Processing");
Console.WriteLine("E(x)it");
Console.WriteLine("*************************************");
string response = "";
string videotype = "";
bool starting = false;
bool exiting = false;
response = Console.ReadLine();
while (response != "")
{
switch (response )
{
case "H":
case "h":
DisplayHelp();
break;
case "W":
case "w":
Console.WriteLine("Video Type set to Workout");
videotype = "W";
break;
case "I":
case "i":
Console.WriteLine("Video Type set to Interview");
videotype = "I";
break;
case "P":
case "p":
Console.WriteLine("Video Type set to Pro Day");
videotype = "P";
break;
case "S":
case "s":
if (videotype == "")
{
Console.WriteLine("Please Select Video Type Before Starting");
}
else
{
Console.WriteLine("Starting...");
starting = true;
}
break;
case "E":
case "e":
Console.WriteLine("Good Bye!");
System.Threading.Thread.Sleep(100);
exiting = true;
break;
}
if (starting || exiting)
{
break;
}
else
{
response = Console.ReadLine();
}
}
if (starting)
{
ProcessFiles();
}
Sadece merak ettiniz: Hangi nesneyi aramayı denediniz. –