How to pass multiple arguments in processStartInfo?
It is purely a string:
startInfo.Arguments = "-sk server -sky exchange -pe -n CN=localhost -ir LocalMachine -is Root -ic MyCA.cer -sr LocalMachine -ss My MyAdHocTestCert.cer"
Of course, when arguments contain whitespaces you'll have to escape them using \" \", like:
"... -ss \"My MyAdHocTestCert.cer\""
See MSDN for this.
What is the correct syntax for passing multiple arguments
Arguments
is a string, which the documentation unhelpfully says is interpreted entirely by the target application. It does say now .NET applications will interpret it, so it really depends on what process you're launching.
The only way to know how to make that arguments string do the right thing for the process you're trying to pass it to is to find out how that process handles its arguments (try running it from the command line if you need to experiment). Mostly you can expect it to expect them to be separated with spaces. It's possible that you can just do something like (assuming C# 6):
$"{latestStudents} {latestTopics}"
But that might not work, depending on what's inside those variables. They may need to be quoted, especially if they contain spaces themselves.
There really is no definitive answer I can give you.
How to pass multiple arguments to a newly created process in C# .net?
In order to pass multiple command line arguments you should separate each with a space and surround it in quotes in case the argument itself contains a space.
string[] args = { "first", "second", "\"third arg\"" };
Process.Start("blah.exe", String.Join(" ", args));
ProcessStartInfo.Arguments accept multiple arguments with double quotes
I got the answer
processStartInfo.Arguments ="/k \"\"" + candlePath + "\" \"" +BundlePath + "\" \"" + wixObjPathToSave +"\"";
I added one more extra double quote at front. Now its working fine. But i have only one doubt why an extra double quote is required?
Process.Start and Process.StartInfo not passing arguments properly
The code you use works fine. It does send the right argument to the program. No doubt.
Some things that could go wrong:
- The file doesn't exist;
- The file doesn't exist in the current working directory, aka the place where
mame
is looking for it (you can try using an non-existing file name in the command line as a test. Is the error the same, then probably the file can't be found. Try to use the full path of the file); - Some permission problems, the error is obscured by the program.
As Sinatr suggested, you could set the current working directory using Directory.SetCurrentDirectory
. Be aware that the current working directory of this program is influenced too, so you might want to consider what you are doing.
You'd better set the working directory of the process you start, using Process.WorkingDirectory
.
How to open multiple files using arguments from windows forms
It very much depends on the application you're launching. Does it support opening multiple files via command line? You would have to check its command line arguments.
If you made the other application, you can pass multiple arguments to the Arguments
property by separating them with spaces. Note that you'll also have to put them in quotes if there are spaces in their paths.
So to launch the application you would do something like this:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = (app + ".exe");
startInfo.Arguments = string.Format("\"{0}\" \"{1}\"", file1, file2);
Process.Start(startInfo);
and then in the other application, you have your Main method:
public static void Main(string[] args)
{
// args[0] contains file1
// args[1] contains file2
}
Related Topics
Error Reading Jobject from Jsonreader. Current Jsonreader Item Is Not an Object: Startarray. Path
How to Perform Join Between Multiple Tables in Linq Lambda
How to Remove Carriage Returns from the Json Output of My Webapi Service
Asp.Net Core Localization Decimal Field Dot and Comma
How to Disable Cursor in Textbox
Could Not Parse the Json File ,Error in Progam.Cs ASP.NET Core
Post Json Array to MVC Controller
How Avoid Adding Duplicates to Database Managed by Entityframework Caused by Seed Method
Client Certificate Not Getting Added to the Request (Certificate Verify)
How to Set Value of Wpf Combobox Item from C# Code
How to Convert Json Date to .Net Datetime During Deserialization
How to Modify a Getter and Setter, to Handle a Null Reference Exception
How to Download a File from a Url in C#
Searching If Value Exists in a List of Objects Using Linq
The Find Element Returns Empty String..Using Xpath Contains,Text()
Rendering Views from External Assemblies in Mvc6