C#/.NET: Closing another process outside the main window
Posted
by eibhrum
on Stack Overflow
See other posts from Stack Overflow
or by eibhrum
Published on 2010-03-28T07:32:41Z
Indexed on
2010/03/28
7:43 UTC
Read the original article
Hit count: 309
Hi,
I just wanna ask your opinion/suggestion on how to 'terminate' a running application/process is C#
Right now, I do have the following codes:
Process myProcess;
private void btnOpen_Click(object sender, RoutedEventArgs e)
{
DirectoryInfo di = new DirectoryInfo(System.Environment.GetFolderPath(Environment.SpecialFolder.Programs));
myProcess = Process.Start(di + @"\Wosk\Wosk.appref-ms"); // opening a file coming for Startup Menu
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
myProcess.Kill(); // not working - Cannot process request because the process has exited
}
I also tried myProcess.Close(); but nothing's happening.
© Stack Overflow or respective owner