Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.74 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Why do I get file not found excpetion with Interaction.Shell method?
  2. int pid = Interaction.Shell(@"D:abc.txt", AppWinStyle.NormalNoFocus, false, -1);
  3.        
  4. int pid = Interaction.Shell(@"notepad.exe", AppWinStyle.NormalNoFocus, false, -1);
  5.        
  6. using (Process process = Process.Start(@"D:abc.txt"))
  7. {
  8.     int pid = process.Id;
  9.  
  10.     // Whether you want for it to exit, depends on your needs. Your
  11.     // Interaction.Shell() call above suggests you don't.  But then
  12.     // you need to be aware that "pid" might not be valid when you
  13.     // you look at it, because the process may already be gone.
  14.     // A problem that would also arise with Interaction.Shell.
  15.     // process.WaitForExit();
  16. }
  17.        
  18. int pid = Interaction.Shell(@"notepad.exe D:abc.txt", false, -1);