我如何在c#中使用参数化过程 [英] how do I use parametrized process in c#
问题描述
大家好,
我想在c#中运行其他应用程序的应用程序。我使用Process来运行exe文件。重要提示是我必须使用带参数的process.start方法。
我称之为exe /
Process.Start(C:\\Users \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \ FileCatalyst.exe,acw.username,acw.password,acw.FileName,acw.FilePath);
问题从FileCatalyst.exe开始
我喜欢下面的内容,它给出了FileCatalyst.exe不包含静态合适的'Main'方法的错误
Hi everyone,
I want to run an application from another application in c#. I use Process to run exe file. Important note is i have to use process.start method with parameters.
I call the exe like
Process.Start("C:\\Users\\ersin\\Desktop\\Projeler\\FileCatalyst\\FileCatalyst\\bin\\Debug\\FileCatalyst.exe", "acw.username,acw.password, acw.FileName, acw.FilePath");
The problem starts at FileCatalyst.exe
I do like below and it gives error that FileCatalyst.exe does not contain a static suitable 'Main' method
namespace FileCatalyst
{
class Program
{
static void Main(string[] args,string username,string password,string file, string path)
{
Console.WriteLine(dsadadsadas");
Console.WriteLine(ewewewewewew");
Console.ReadKey();
}
}
}
问题是如何获取FileCatalyst.exe上的参数?
谢谢
The question is how do i take the parameters on FileCatalyst.exe?
Thanks
推荐答案
我已经解决了问题
首先,我已经了解到System.Diagnotistic .Process.Start(string,string)接受两个参数即字符串。我将第一个参数设置为exe文件,将第二个参数设置为所有其他参数的组合。
i have solved the problem
Firstly, i have learned that System.Diagnotistic.Process.Start(string ,string) takes two parameters that are strings. I set the first parameter to exe file and second parametre to combine of all others parametres as
string parameter = acw.username + "," + acw.password + "," + acw.FileName + "," + acw.FilePath;
string path = "C:\\Users\\ersin\\Desktop\\Projeler\\FileCatalyst\\FileCatalyst\\bin\\Debug\\FileCatalyst.exe";
var process = Process.Start(path, parameter);
在exe部分我用逗号分割参数并得到所有变量
And at the exe part i split the parameter by comma and get all variables
这篇关于我如何在c#中使用参数化过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!