I'm developing a program, where the user can start any application from the program. The program will store the process id of the application started, so it can terminate it when the user wants to.
Process application = new Process();
application.StartInfo.FileName = txtApplicationToOpen.Text;
if (application.Start())
{
Debug.WriteLine("started");
lstCurrentlyOpenApplications.Items.Add(txtApplicationToOpen.Text);
_openApplications.Add(application);
}
The problem I'm facing :
the part in if(application.Start()) gets called, only if I'm opening say exe files, or an excel file ( though the PID returned by excel file doesn't kill the excel program ).
When I open a mp3, mp4, or a image file, it doesn't enter the if statement
When trying to get the ID of the process, it returns the following error
System.InvalidOperationException: No process is associated with this object.
