1

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!

Kevdog777
  • 908
  • 7
  • 20
  • 43

2 Answers2

2

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.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
  • Thank you for that. I tried this before once, and it opened PFE but not the file1.text. But I have just done what you said, and it is working now. Thank you! – Kevdog777 Jul 20 '11 at 08:14
1

The second parameter is arguments to the command, notepad doesn't need an argument name, just the file name to work.

Perhaps PFE takes a named argument like: pfe32.exe -path:C:\myfile.txt

Adam Houldsworth
  • 63,413
  • 11
  • 150
  • 187