我想以编程方式从 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();
这将打开一个网络浏览器窗口并下载文件,这不是我想要的。如果我追加
wordProcess.StartInfo.Verb = "OpenAsReadOnly"
按照( the documentation )我在 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\"";
关于c# - 从 WPF 通过 URL 打开文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10988204/