简体   繁体   English

使用 Process.Start 在 PFE 中打开一个文本文件

[英]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.我有一个程序,一旦完成比较 2 个文件,它会将所有差异写入一个文本文件。 I have 2 radio buttons, one to open in Notepad and the other to open in PFE (Programmers File Editor).我有 2 个单选按钮,一个在记事本中打开,另一个在 PFE(程序员文件编辑器)中打开。

My PFE.exe is in "C:\Program Files (x86)\PFE\PFE.exe" and Notepad is where it normally is by default.我的 PFE.exe 位于“C:\Program Files (x86)\PFE\PFE.exe”中,而记事本默认位于通常的位置。

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);"现在,只需 "Process.Start("notepad.exe", File1.Text);" works fine, without the if statements.工作正常,没有 if 语句。

So, therefore, my question is - Can you help me figure out why PFE won't open with the text file?所以,因此,我的问题是 - 你能帮我弄清楚为什么 PFE 不能用文本文件打开吗?

Thank you guys!感谢你们!

PFE32.exe is not found, because it is not in any of the directories declared in the PATH environment variable.找不到 PFE32.exe,因为它不在PATH环境变量中声明的任何目录中。
You need to either add C:\Program Files (x86)\PFE to the path variable or call PFE32.exe with the full path.您需要将C:\Program Files (x86)\PFE添加到路径变量或使用完整路径调用 PFE32.exe。

The second parameter is arguments to the command, notepad doesn't need an argument name, just the file name to work.该命令的第二个参数是 arguments,记事本不需要参数名称,只需文件名即可。

Perhaps PFE takes a named argument like: pfe32.exe -path:C:\myfile.txt也许 PFE 采用命名参数,例如: pfe32.exe -path:C:\myfile.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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