执行与C#.NET外部EXE [英] Execute an external EXE with C#.NET
本文介绍了执行与C#.NET外部EXE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我执行在C#中的过程,但我希望能够做到这一点,而无需指定的路径。我在哪里可以将可执行项目中,以使code发现它wuthout指定路径?
目前我有:
的ProcessStartInfo PSI =新的ProcessStartInfo();
psi.FileName = @C:\\文档\\ wkhtmltopdf.exe
这运行正常,但我想和落得是:
的ProcessStartInfo PSI =新的ProcessStartInfo();
psi.FileName =wkhtmltopdf.exe;
我试过把EXE文件的文件夹中的项目,在项目的根,在斌
项目的文件夹 - 所有失败
解决方案
的ProcessStartInfo PSI =新的ProcessStartInfo();
psi.FileName =wkhtmltopdf.exe;
psi.WorkingDirectory = Environment.CurrentDirectory;
过程PROC =的Process.Start(PSI);
I am executing a process in C# but I want to be able to do it without specifying the path. Where can I place the executable within the project so that the code finds it wuthout specifying a path?
At the moment I have:
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = @"C:\Docs\wkhtmltopdf.exe";
Which runs fine but what I'd like to end up with is:
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "wkhtmltopdf.exe";
I've tried placing the EXE in a folder in the project, in the root of the project, in the bin
folder of the project - all unsuccessfully.
解决方案
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = "wkhtmltopdf.exe";
psi.WorkingDirectory = Environment.CurrentDirectory;
Process proc = Process.Start(psi);
这篇关于执行与C#.NET外部EXE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文