How to start System.Diagnostics.Process with multiple arguments?

ipjyo used Ask the Experts™

I have the below code to start a process and works fine.
But I need to pass another argument like s.FilePath.

How can we do this?

Thanks for any help.

Process P = new Process();
                    P.EnableRaisingEvents = true;
                    P.Exited += P_Exited;
                    P.StartInfo.FileName = batchfilename;
                    P.StartInfo.Arguments = s.Filename;

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can try placing all of your arguments into a parameters collection:

Dictionary <string, object> parms = new Dictionary<string, object>();
parms.Add("Filename", s.Filename);
parms.Add("FilePath", s.Filepath);

P.StartInfo.Arguments = parms;
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
You can also try just separating them with spaces:

    P.StartInfo.Arguments = arg1 + " " + arg2 + " " + s.Filename;


Thank you.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial