c# - Take user input and use it as Process -
so basically, have openfiledialog user select location. made display directory in textbox. want have button take directory , start using processstartinfo
.
openfiledialog, showing in textbox:
public void button4_click(object sender, eventargs e) { openfiledialog ofd = new openfiledialog(); ofd.title = "open arma 3"; ofd.filter = "exe file|*.exe"; if (ofd.showdialog() == system.windows.forms.dialogresult.ok) { textbox1.text = ofd.filename; } }
process:
private void button3_click(object sender, eventargs e) { processstartinfo startinfo = new processstartinfo(); startinfo.filename = //result openfiledialog should here startinfo.arguments = @"-window -usebe -mod=e:\aaron\addons\@cba_a3"; process.start(startinfo); }
since save result of openfiledialog in textbox1, can access in button3_click event handler.
to fill startinfo.filename:
*i added isnullorwhitespace check, application doesn't start process if textbox1.text empty.
if(!string.isnullorwhitespace(textbox1.text) { processstartinfo startinfo = new processstartinfo(); startinfo.filename = textbox1.text startinfo.arguments = @"-window -usebe -mod=e:\aaron\addons\@cba_a3"; process.start(startinfo); }
Comments
Post a Comment