c# - Passing parameters from one app to the other -


following on thread starting application before target application

i have application gets passed parameter (a filename) , registry work before opening microsoft infopath.

i need open infopath parameter passed original application.

here how open infopath

system.diagnostics.process prc = new system.diagnostics.process(); prc.startinfo.arguments = convertarraytostring(constants.arguments); //prc.startinfo.arguments = "hello"; prc.startinfo.filename = constants.pathtoinfopath; prc.start(); 

note when set arguments "hello" infopath pops message saying cannot find file "hello" when set constants.arguments error , windows asks me if want debug or close applicatiion.

here how set constants.arguments in main(string[] args)

static void main(string[] args) {     constants.arguments = args;     //... } 

and here convertarraytostring

private string convertarraytostring(string[] arr) {      string rtn = "";     foreach (string s in arr)     {         rtn += s;     }      return rtn;  } 

i suppose format of parameter causing error, idea why?

the value of arguments after being stringed is

c:\users\accountname\desktop\hse-000403.xml 

edit:

thanks n k's answer.

the issue in order application open when infopath files opened, have changed name of infopath.exe infopath0.exe , application called infopath.exe , in infopath folder, when files opened application opens.

now when not change name (eg leave infopath.exe) works expected, if called other error.

unfortunately need application open first.

i tried below , it's works fine. let me know this. (don't forget change path files)

class program {     static void main(string[] args)     {         system.diagnostics.process prc = new system.diagnostics.process();         prc.startinfo.arguments = string.join("", constants.arguments);         prc.startinfo.filename = constants.pathtoinfopath;         prc.start();     } } public class constants {     public static string pathtoinfopath = @"c:\program files (x86)\microsoft office\office14\infopath.exe";     public static string[] arguments = new string[] { @"c:\users\accountname\desktop\hse-000403.xml" }; } 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -