-2

I am trying open a downloaded file in it's default desktop application e.g. if that's a '.txt' file this should open in notepad and if it's a ('.docx') file, this should be opened using 'wordpad.exe' (if MS Word is not installed). I am trying to open the file using very common 'Process.Start()' method:

System.Diagnostics.Process.Start(path);

where 'path' is the complete path to the file i.e. c:\somefolder\file.extension

Code is working in the sense that it's being executed without any errors (debugged this as well), and when I check the task manager, relevant process (notpad.exe, wordpad.exe, based on file being opened) is there in the process list. BUT, The desktop application is never launched to show the file. Please guide what am i missing.

Muhammad Murad Haider
  • 1,357
  • 2
  • 18
  • 34

2 Answers2

1

Try this:

Process p = new Process();
p.StartInfo.UseShellExecute = true;
p.StartInfo.FileName = path;
p.Start();
user11909
  • 1,235
  • 11
  • 27
0

Based on what you provided there isn't much information to go on. A simple step would be to check what the value of the variable is and paste it in run to see if it actually executes. It might be a tiny issue.

RandomCoder
  • 134
  • 9