C#OneDrive for Business/SharePoint:从本地同步文件获取服务器路径 [英] C# OneDrive for Business / SharePoint: get server path from locally synced file

查看:222
本文介绍了C#OneDrive for Business/SharePoint:从本地同步文件获取服务器路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写WPF C#应用程序,并希望获取本地同步文件的SharePoint URL.

I'm writing a WPF C# application, and would like to obtain the SharePoint URL of a locally synced file.

在Windows资源管理器中,用户可以右键单击已同步的OneDrive文件夹中的文件,选择"OneDrive for Business"菜单和复制链接".这提供了已同步文件的SharePoint URL.有没有办法在C#中复制它?

In Windows Explorer, the user can right click on a file in the synced OneDrive folder, select "OneDrive for Business" menu and "Copy link". This provides the SharePoint URL of the synced file. Is there a way to replicate this in C#?

目前,如果我从应用程序内部使用FileOpenDialog引用文件,则只能获取本地物理路径(例如c:\ onedrive ... \ file.txt).如何使用本地同步的文件获取SharePoint URL?

At the moment, if I reference the file using a FileOpenDialog from within my application, I only get the local physical path (e.g. c:\onedrive...\file.txt). How can I use the locally synced file to get the SharePoint URL?

推荐答案

我还在寻找一种解决方案,用于在OneDrive同步文件资源管理器中将SharePoint网址获取到文件. 我注意到您在C:\ Users \ uid41890 \ AppData \ Local \ Microsoft \ OneDrive \ settings \ Business1 {GUID} .ini下获得OneDrive同步文件夹和SharePoint GUID之间的映射 示例:

I am also looking at a solution for getting the SharePoint url to a file in OneDrive Synced File Explorer. I have noticed you get under C:\Users\uid41890\AppData\Local\Microsoft\OneDrive\settings\Business1{GUID}.ini a mapping between your OneDrive synced folder and the SharePoint GUID Example:

libraryScope = 1 630c2a866d9c458b81060eff107887ed+1 5 "GUIDEs" "Documents" 4 "https://continental.sharepoint.com/teams/team_10000035" "8d4b558f-7b2e-40ba-ad1f-e04d79e6265a" e0266a43caf347238f684bab486f4e51 e0d25dcb1a014f5f86d787984f6327c2 4f86b3e3e54e42e0bb0f7a58eadf0335 0 "" 0 4cde5c00-3fe3-4162-b831-d8ef440e1593
libraryFolder = 0 1 8bbfe07dfeff41cea7ab5da4a554592a+1 1558084235 "D:\DSUsers\uid41890\Continental AG\GUIDEs - General" 2 "General" bd0c1b7c-2a1f-4492-8b1b-8e152c9e0c26

libraryScope = 1 630c2a866d9c458b81060eff107887ed+1 5 "GUIDEs" "Documents" 4 "https://continental.sharepoint.com/teams/team_10000035" "8d4b558f-7b2e-40ba-ad1f-e04d79e6265a" e0266a43caf347238f684bab486f4e51 e0d25dcb1a014f5f86d787984f6327c2 4f86b3e3e54e42e0bb0f7a58eadf0335 0 "" 0 4cde5c00-3fe3-4162-b831-d8ef440e1593
libraryFolder = 0 1 8bbfe07dfeff41cea7ab5da4a554592a+1 1558084235 "D:\DSUsers\uid41890\Continental AG\GUIDEs - General" 2 "General" bd0c1b7c-2a1f-4492-8b1b-8e152c9e0c26

您还在注册表Computer \ HKEY_CURRENT_USER \ Software \ Microsoft \ OneDrive \ Accounts \ Business1 \ ScopeIdToMountPointPathCache中具有此映射

You also have this mapping in the registry Computer\HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts\Business1\ScopeIdToMountPointPathCache

从GUID,您可以使用 SPWeb.GetFile(Guid) 不幸的是,GetFile函数似乎仅在服务器端可用.

From the GUID you could get the path using SPWeb.GetFile(Guid) unfortunately the GetFile function seems only to be available on the server side.

如果您可以为给出返回SharePoint URL的本地OneDrive文件路径的独立功能,请在这里分享您的解决方案.

If you can make a standalone function given a local OneDrive file path that returns the SharePoint url, I would greatly appreciate you share your solution here.

这篇关于C#OneDrive for Business/SharePoint:从本地同步文件获取服务器路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆