wpf - How to change the default program to open any Word documents, using C#? -


in wpf application, want open word documents in word 2007 or above, whether or not default program opening word documents word 2007. if default program open word documents open office, want open them in word 2007+.

how can this?

this doesn't have wpf.

you'll need word installed or add the folder in located path environment variable.

assuming file name variable called filename , full path of winword.exe stored in wordpath (or winword.exe in path), need -

processstartinfo startinfo = new processstartinfo                                          {                                              createnowindow = false,                                              arguments = filename,                                              filename = wordpath                                          }; process wordprocess = process.start(startinfo); 

note 1 - filename passed directly word. if path contains white spaces you'll have wrap in "". like

filename = string.format("{0}{1}{2}",                                  filename.startswith("\"") ? "" : "\"",                                  filename,                                 filename.endswith("\"") ? "" : "\""); 

note 2 - word has other command line arguments different purposes, other uses see here http://support.microsoft.com/kb/210565.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -