process.startinfo opens new instance of process
Hi i have requirement where in i need to open a word document file and if already any word document is open, the new file should open in the already open word document window
below is my code.
/*---------------------------------------------------------------------*/
using System.Diagonostics.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "WINWORD.EXE";
startInfo.Arguments = "c:\myfile.doc";
foreach (Process thisproc in Process.GetProcessesByName("WINWORD"))
{
if (!thisproc.CloseMainWindow())
{
thisproc.Kill();
}
}
Process.Start(startInfo);
/*--------------------------------------------------------------------*/
The above code is opening the file myfile.doc but it is closing all the opened word files and then opening the myfile.doc in a new instance, IF i remove the " process.kill " then its still opening the myfile.doc in a new instance. but my requirement is , lets say file1.doc is already open then when i run my programe this should open myfile.doc in the same instance of file1.doc ..
|