I want to open the document with wordpad.exe but it is still opening with microsoft word
I currently have:
string fullPath = helpFiles[index];
ProcessStartInfo psi = new ProcessStartInfo("wordpad.exe");
psi.FileName = Path.GetFileName(fullPath);
psi.WorkingDirectory = Path.GetDirectoryName(fullPath);
psi.Arguments = fullPath;
Process.Start(psi);
I asume fullPath
is your document's name. You're setting the FileName
property to the document which means it'll open in the default document editor (Word in this case).
The overload of ProcessStartInfo
you're using sets the filename for you but you're replacing that value with Path.GetFileName(fullPath);
which is why wordpad.exe
is completely ignored. Set the FileName
as wordpad
and the arguments
as your file path (i.e remove your FilePath line).
ProcessStartInfo psi = new ProcessStartInfo("wordpad");
psi.WorkingDirectory = Path.GetDirectoryName(fullPath);
psi.Arguments = fullPath;
Process.Start(psi);