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

https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.arguments(v=vs.110).aspx


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -