Search code examples
c#visual-studio-expresssystem.diagnosticsnotepad

Using Process.Start to open a text file in PFE


I wonder if you can help me with this one. I have looked on Google but found nothing.

I have a program, that once it is finished comparing 2 files together, it writes out all the differences to a text file. I have 2 radio buttons, one to open in Notepad and the other to open in PFE (Programmers File Editor).

My PFE.exe is in "C:\Program Files (x86)\PFE\PFE.exe" and Notepad is where it normally is by default.

My code is:

using System.Diagnostics;

...

if (radioButton1.Checked)
        {
            Process.Start("notepad.exe", File1.Text);
        }
        if (radioButton2.Checked)
        {
            Process.Start("PFE32.exe", File1.Text);
        }

Now, just "Process.Start("notepad.exe", File1.Text);" works fine, without the if statements.

So, therefore, my question is - Can you help me figure out why PFE won't open with the text file?

Thank you guys!


Solution

  • PFE32.exe is not found, because it is not in any of the directories declared in the PATH environment variable.
    You need to either add C:\Program Files (x86)\PFE to the path variable or call PFE32.exe with the full path.