微软办公文档显示Sharepoint URL而非本地地址

5
情况:OneDrive for Business将Sharepoint网站文档库中的文件同步到本地目录。
C:\Users\users\Sharepoint\Library\Test.pttx

然而,使用 PowerPoint InterOp:

presentation.Path

是:

https://company.sharepoint.com/Library/Shared%20Documents/

Sharepoint的正确路径是什么?

我如何访问本地目录?

更新:我在MSDN上找到了一个相似的问题,但没有答案。

2个回答

2
如果我理解正确,您想在Powerpoint(VSTO)中以某种方式获取同步目录的本地路径?类似于Powerpoint对象模型中的方法 presentation.GetLocalPath()
我不知道为什么(在您的问题的 MSDN链接 中),MSFT CSG工程师说这是不可能的。
引用:
抱歉,经过进一步调查,这是不可能的。对于Word应用程序,文件存储在OneDrive上,“离线”是OneDrive的缓存模式,对于Word应用程序来说是透明的(Word应用程序只知道它是OneDrive上的文档),因此当您检查打开的文档位置时,位置是“http:/d.docs.live.net/xxxx/xx.docx”,而不是“C:\XXX\XXX”。
本文向您展示如何更改计算机上同步SharePoint库的位置。显然,Powerpoint Interop Library中没有方法,但这是完全可能的。
1)我的第一个想法是查看OneDrive for Business同步应用程序向导是否保存任何注册表键或类似内容(使用ProcessMonitor),但它可能会将本地目录存储在云中。
2)我的第二个想法有点超前,只需在https://company.sharepoint.com/Library/Shared%20Documents/LocalDrivePath.txt中放置一个文本文件,然后创建一个名为presentation.GetLocalPath()的扩展方法,并使用WebClient类下载字符串。

enter image description here

伪代码:
public string GetLocalPath(this Microsoft.Office.Interop.PowerPoint.Presentation presentation)
{
    WebClient client = new WebClient();
    string localPath = client.DownloadString(presentation.Path + "LocalDrivePath.txt");

    //Some good old protective programming to quickly identify the problem if the file doesn't exist
    if (!string.IsNullOrEmpty(localPath)) throw new Exception("Issue: LocalDrivePath.txt not found in " + presentation.Path + Environment.Newline + "Please add the file for this Office Documents' sync'd (offline) local folder to be identified.");

    return localPath;
}

这样调用它:
presentation.GetLocalPath();

非常感谢您关注此事。对于 1) 没有写入任何注册表键,我们不知道它存储路径的位置,对吗?对于 2) 我是否正确理解,我至少需要知道位置才能将其存储在 .text 中?我的意思是,如果我知道位置,我可以将其存储在任何地方,是吗?另一个想法是在本地搜索文件并找到路径部分。 - Cilvic
第三种方法(查找文件)似乎是一个好的选择,如果使用第二种方法后文件夹应该发生变化。你是对的,一旦找到目录,你可以将其存储在任何地方,在SharePoint中的txt文件最容易演示。 - Jeremy Thompson

2
根据这篇文章,同步文件夹可以在这个多字符串注册表值中查找:

HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\Internet\LocalSyncClientDiskLocation

假设你的本地路径和SharePoint URL类似于

C:\Users\User\SharePoint\Library - Documents\Folder\SubFolder\Document.pptxhttps://***.sharepoint.com/Library/Shared%20Documents/Folder/SubFolder/Document.pptx

你可以尝试从URL中提取本地部分Folder/SubFolder/Document.pptx,将其添加到从注册表值检索到的本地文件夹路径中,并检查文件是否存在。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接