Reputation: 137
string format="@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\",Id, ProjectId, refresh";
im storing the above as a string and passing it to processstart(appName,format). the function is as follows. im getting the mentioned error when passing the arguments
public void ProcessStart(string AppName, string format)
{
try
{
ProcessStartInfo StartInfo = new ProcessStartInfo(System.Configuration.ConfigurationManager.AppSettings[AppName].ToString());
StartInfo.Arguments = string.Format(format);
StartInfo.CreateNoWindow = true;
StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(StartInfo);
}
catch (Exception ex)
{
throw ex;
}
}
Upvotes: 0
Views: 108
Reputation: 460238
You cannot add the arguments within the format-string, this should work:
string format = "@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\"";
var args = string.Format(format, Id, ProjectId, refresh);
StartInfo.Arguments = args ;
Upvotes: 2
Reputation: 17600
Your format string
looks like aggregated string with parameters.
Change your string
format to:
string format="@\"\"\"{0}\"\" \"\"{1}\"\" \"\"{2}\"\"\";
and then
StartInfo.Arguments = string.Format(format, Id, ProjectId, refresh);
Upvotes: 1