Вопрос

At the moment I start a EXE-File so:

    System.Diagnostics.ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo();
    processStartInfo.FileName = "Stackoverflow.exe";
    processStartInfo.WorkingDirectory = ConfigurationManager.AppSettings["Path"] + name + @"\bin";
    System.Diagnostics.Process.Start(processStartInfo);

If i want to add Parameters , I would do it here right?:

System.Diagnostics.Process.Start(processStartInfo, params);

If not, where?

And the other thing is, that I would like to save the params for the exe, does it happen automatically or do I have to set this, while opening? If so, then how I could achieve that?

EDIT:

What I mean with save is.. I got a Form with Textbox, from there u can start a EXE, by example Stackoverflow.exe and in the Textbox u could write: "-hello" , now next time u open the form and select the EXE in the FORM, there is "-hello" still written, that means, it has been saved, thats what I want

Это было полезно?

Решение

Set the ProcessStartInfo.Arguments property. It's just a string of space-separated arguments. You'll need to quote any path names which include spaces, etc. It's a bit of a pain, but that's what's there :(

It's not really clear what you mean by "saving" the parameters - nothing will remember the arguments you last used to start a process and apply the same things next time, no. You'd have to do that yourself. How you do that will depend on what else you're doing - you could use a per-user setting, for example, the same way as any other setting.

Другие советы

You can simply pass arguments in the second argument to the Process.Start method. Ie:

Process.Start("IExplore.exe", "www.northwindtraders.com");

Alternatively you can use ProcessStartInfo. I.e:

ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);

There are some other useful examples in msdn's class reference

You would set arguments in processStartInfo.Arguments.

I don't know what you mean by saving them, but it won't do anything as it's just a string. You can do whatever you want with this string yourself.

You could also use the Arguments property in your ProcessStartInfo class.

Also, the arguments will not be saved and why should they? If you create a shortcut on your desktop, then these arguments are stored there and your executable will be called with the stored arguments, but that has nothing to do with your application.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top