简体   繁体   中英

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!

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM