Please find below my piece of code. I crawled through Stack Overflow on how to get notified if a process is terminated and used the suggestions in my code as below(last 3 lines).
private void button1_Click(object sender, EventArgs e)
{
folderBrowserDialog1.ShowDialog();
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
//startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C rep_cmd "+textBox2.Text+" -text "+folderBrowserDialog1.SelectedPath+"\\";
process.StartInfo = startInfo;
System.Diagnostics.Process.Start(startInfo);
if (process.HasExited == true)
MessageBox.Show("Process done successfully!");
}
But, when I run the program, I get a runtime exception saying "No process is associated with this object". Clueless of how to rectify this.
Kindly help.