I have one button and one textbox on form. When I click on the button, Microsoft Word is started. When the user closes Word, I want to get the file name that the user saved his work under to show up in the text box.
I am using the following code for button_click:
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:\Program Files\Microsoft Office\Office12\winword.exe");
psi.RedirectStandardOutput = true;
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
System.Diagnostics.Process listFiles;
listFiles = System.Diagnostics.Process.Start(psi);
System.IO.StreamReader myOutput = listFiles.StandardOutput;
listFiles.WaitForExit();
if (listFiles.HasExited)
{
System.IO.FileInfo ff = new System.IO.FileInfo(myOutput.ToString());
string output = myOutput.ReadToEnd();
this.processResults.Text = output;
}