How to pass parameters to another process in c# -
i created application launches processes following code
string [] args = {"a", "b"}; process.start ("c: \ \ demo.exe" string.join ("", args));
i able pass parameters application process i've launched.
where have enter parameters in project of process i've launched? tried put them in
static void main (string [] args) {...
but not available in other forms. help
process p= new process(); p.startinfo.filename = "demo.exe"; p.startinfo.arguments = "a b"; p.start();
or
process.start("demo.exe", "a b");
in demo.exe
static void main (string [] args) { console.writeline(args[0]); console.writeline(args[1]); }
you asked how save these params. can create new class static properties , save these params there.
class paramholder { public static string[] params { get; set;} }
and in main
static void main (string [] args) { paramholder.params = args; }
to params in place of program use:
console.writeline(consoleparamholder.params[0]); console.writeline(consoleparamholder.params[1]);
etc.
Comments
Post a Comment