使用One Drive for Buisiness时的文件路径

时间:2016-10-19 10:38:33

标签: c# ms-word onedrive

我有一个MS Word加载项,可以使用位于One Drive for Business的本地同步区域中的文件。

我在C:.. \ OneDrive .. \ MyDir \ File.docx创建文件 稍后我会创建一个FileInfo对象:

var file = new FileInfo(doc.FullName);

调试时这很好用。但是,当我正常运行代码时,doc.FullName是Web路径https://..-my.sharepoint.com/personal/../MyDir/File.docx 这打破了FileInfo对象。

为什么MS Word会返回uri而不是本地文件路径? 为什么调试我的加载项时MS Word不一致? 以及我是否可以围绕这个编码的任何想法?

- 编辑 -

有三种行为:

  1. 运行Winword.exe(doc.FullName = http://[OneDrive]

  2. 运行Winword.exe并附加到Visual Studio中的进程(doc.FullName = http://[OneDrive]

  3. 按Visual Sudio中的F5进行调试(doc.FullName = C:.. \ OneDrive ..)

1 个答案:

答案 0 :(得分:2)

Word can open both local files and cloud files. When the latest OneDrive sync client is installed and you open a local file that's sync'd to the cloud, Word will discover its cloud URL and prefer using that, because it lights up cloud-based features like coauthoring. If it's possible for your plugin to be tweaked to support cloud-only files that don't have a local copy, then that solution will probably work for OneDrive-sync'd file as well.