开发者

Open Word Document with WPF without open dialog

开发者 https://www.devze.com 2022-12-28 13:14 出处:网络
I have the path to a Word document saved in an SQL Database. I am able to retrieve the p开发者_C百科ath but I cannot work out the best approach to open the Word document from WPF without using the O

I have the path to a Word document saved in an SQL Database.

I am able to retrieve the p开发者_C百科ath but I cannot work out the best approach to open the Word document from WPF without using the OpenFileDialog. I've given up any thoughts of embedding Word in WPF as it has too many gotchas.

I just want to be able to click a button or hyperlink and using the retrieved document path, open Word.


Try something like

Process wordProcess = new Process();
wordProcess.StartInfo.FileName = pathToYourDocument;
wordProcess.StartInfo.UseShellExecute = true;
wordProcess.Start();

By setting UseShellExecute to true it will open the document using the default program, in your case Word.

0

精彩评论

暂无评论...
验证码 换一张
取 消