开发者

Launching a .pl file using Process.Start

I have been using Process.Start to launch executables (.exe) files. Now I need to execute a .pl file with some arguments. can I still use Process.Start or I need a different approach?

EDIT :- I am having to mark this question unanswered as I am getting the following error when I try to call the perl file from the CSharp code:- (When I call the same from the commandline with the same path and parameters, It works fine)

System.ApplicationException: StartProcess Failed System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform)

Please note that when I try to call an .exe file f开发者_如何转开发rom my C# code, I dont see the above error.

EDIT:- Checking the following link now:- How do I call Perl script in C# application? It seems that the ProcessStartInfo constructor has two parameters - fileName and the arguments. You should set Perl.exe as the fileName and the "argument" would be your perl file (.pl) with other arguments It accepts. Checking now....


You certainly can :) you can also pass it arguments by adding them after the file name in

Process.Start(file.pl args1 args 2);

It will load the file with your default application for .pl files, the other option is to specify the software then pass your file as a parameter providing you have the right software to handle the file it should be fine

Process.Start() can be pointed at any file and it will be opened using the default software or that which you specify, it need not be an executable.


Yes you can, Process.Start() takes a string parameter, what you pass for this parameter does exactly the same thing it would do if you entered the same string in the windows start -> run dialog.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜