c# - Want to make a button to open an Google Chrome, Cinema 4D etc in WPF -
i tried solutions everywhere, got heres code
namespace elysium.metrowindow { /// <summary> /// interaction logic mainwindow.xaml /// </summary> public partial class mainwindow : elysium.controls.window { public mainwindow() {} } }
and right click menu part (its elysium.demo program if want's see full app)
<controls:window.applicationbar> <controls:applicationbar> <!-- right click on ui open application bar --> <controls:dropdowncommandbutton header="google chrome" clickmode="press" /> <controls:dropdowncommandbutton header="skype" clickmode="press" /> <controls:dropdowncommandbutton header="microsoft visual 2012" clickmode="press" /> <controls:dropdowncommandbutton header="minecraft" clickmode="press" /> <controls:dropdowncommandbutton header="cinema 4d" clickmode="press" /> <controls:dropdowncommandbutton header="counter strike 1.6" clickmode="press" /> </controls:applicationbar> </controls:window.applicationbar>
so, how can add right click menu open program have tried process.start("c:\apppath\appname.exe") , button
private void button1_click(object sender, routedeventargs e) { process chrome = new process(); chrome.startinfo.filename = "c:\program files\google\chrome\application\chrome.exe"; // needs full path chrome.startinfo.arguments = ""; // if have arguments bool result = chrome.start(); } } }
you didn't provide information on went wrong or if there error, tried out (note chrome directory different, double check filename) , adding @ file name worked.
process chrome = new process(); //create process chrome.startinfo.filename = @"c:\program files\google\chrome\application\chrome.exe"; // needs full path chrome.startinfo.arguments = ""; // if have arguments chrome.start();
the @
symbol allows use reserved keyword in example lets specify string without having escape characters (using //
instead of /
)
also not sure bool result
for, wasn't nessessary right now.
more information on process
Comments
Post a Comment