wpf - C# - How to open a doc with word using arguments -
i want have program open word , specific document, using word example. useful in other situations, i'd know how arguments. have bit of code open program, , code display error message if file path not exist here:
private void startprocess(string path) { processstartinfo startinformation = new processstartinfo(); startinformation.filename = path; process process = process.start(startinformation); process.enableraisingevents = true; } private void clickfunc(object sender, routedeventargs e) { if (file.exists(programpath)) { startprocess(programpath); } else { messagebox.show("specified path not exist, please try again.", "bad file path error", messageboxbutton.ok); } }
and wondering how add arguments it. thanks!
you can add command line arguments using arguments property of processstartinfo class.
something this:
processstartinfo startinfo = new processstartinfo("winword"); startinfo.arguments = "/a /b";
also can specify command line arguments string in processstartinfo constructor.
check link msdn
Comments
Post a Comment