It seems that Interaction.Shell cannot open the application with a linked document. (a) the corresponding MSDN page does not say this (although the example for the PathName parameter seems erroneous then) and (b) even if D:\abc.txt exists, it fails.
Alternatively, you can use the System.Diagnostics.Process class:
using (Process process = Process.Start(@"D:\abc.txt")) { int pid = process.Id;
Note that D:\abc.txt must exist, or you still get a FileNotFoundException .
Refresh If you really need to use Interaction.Shell , you can use the following
int pid = Interaction.Shell(@"notepad.exe D:\abc.txt", false, -1);
Personally, I would go with the Process class, since it usually provides more efficient processing of the running process. In this case, it also frees you from "knowing" which program is associated with .txt files (if you do not always want to use notepad.exe ).
source share