开发者

calling executable from a background process and passing a parameter to it

I have an Console application which runs as background process and there is an exe which needs to be called.This exe takes complete fill path as parameter and then encrypts that file. I did this way :

Process.Start( "myapp.e开发者_如何学Goxe" );

But what i want is this :

Process.Start( "myapp.exe file1.txt" ); // File1 is parameter of that exe

But this is not working. Looking for help & advice.

Thanks :)


You want to use the ProcessStartInfo class.

See http://msdn.microsoft.com/en-us/library/system.diagnostics.process.startinfo.aspx and http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx for an example on how to use this.

Use the Arguments property to set your arguments.


Use something like this:

Process p = new Process();

p.StartInfo.UseShellExecute = false;

p.StartInfo.FileName = "myApp.exe";

p.StartInfo.Arguments = "file1.txt";

p.Start();


Try Process.Start("myapp.exe", "file1.txt");


Process.Start("[drive]:\[directory]\myapp.exe", "file1.txt");

Substitute the actual drive and directory where indicated


Process.Start(<the nameof the process>,<the parameters>) In your case

Process.Start("myapp.exe","file1.txt")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜