C# 从WPF按URL打开文件

C# 从WPF按URL打开文件,c#,.net,process,C#,.net,Process,我希望以编程方式从SharePoint URL打开文档 我有以下代码: Process wordProcess = new Process(); wordProcess.StartInfo.FileName = "http://sharepoint/blank_site_1/document library 1/word document.docx"; wordProcess.StartInfo.UseShellExecute = true; wordProcess.Start();

我希望以编程方式从SharePoint URL打开文档

我有以下代码:

Process wordProcess = new Process();
wordProcess.StartInfo.FileName 
    = "http://sharepoint/blank_site_1/document library 1/word document.docx";
wordProcess.StartInfo.UseShellExecute = true;
wordProcess.Start();
这将打开一个webbrowser窗口并下载文件,这不是我想要的。如果我附加

wordProcess.StartInfo.Verb = "OpenAsReadOnly"
根据()我在
wordProcess.Start()
处得到一个Win32异常“参数不正确”,尽管在调试器中检查时动词出现在
wordProcess.StartInfo.Verbs


我有一个POC,它通过从注册表中提取默认程序,生成一个命令并用文件名启动程序来实现这一点,但如果这个问题很容易解决的话,我宁愿不走这条路,因为我只想用默认程序打开一个文件(其路径恰好看起来像URL)。

只是一个猜测,试试这个:

wordProcess.StartInfo.FileName = "winword.exe";
wordProcess.StartInfo.Arguments = "\"http://sharepoint/blank_site_1/document_library_1/word document file.docx\"";

谢谢你的回复。指定winword.exe是我想要避免的-我只想用不是web浏览器的默认程序打开文档(恰好位于URL处)。我开始认为这可能是不可能的。不幸的是,如果你指定一个URL,默认的应用程序是浏览器。无论如何,如果安装了Word,那么它就在路径上,所以你不必确切知道winword.exe在用户机器上的位置。啊,我想是的。真可惜。谢谢你抽出时间。我对你的答案进行了编辑,以包括围绕论点的引用,这显然是必要的。