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

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

问题描述

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

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

目前,如果我在应用程序中使用 FileOpenDialog 引用文件,我只会获得本地物理路径(例如 c:onedrive...file.txt).如何使用本地同步文件获取 SharePoint URL?

解决方案

我也在寻找一种解决方案,用于将 SharePoint url 获取到 OneDrive 同步文件资源管理器中的文件.我注意到您在 C:Usersuid41890AppDataLocalMicrosoftOneDrivesettingsBusiness1{GUID}.ini 下获得了 OneDrive 同步文件夹和 SharePoint GUID 之间的映射示例:

<代码> libraryScope = 1 630c2a866d9c458b81060eff107887ed + 1 5 引导", 文档" 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:DSUsersuid41890Continental AGGUIDEs - General" 2 "General" bd0c1b7c-2a1f-44592a+1 1558084235 8

您在注册表 ComputerHKEY_CURRENT_USERSoftwareMicrosoftOneDriveAccountsBusiness1ScopeIdToMountPointPathCache 中也有这个映射

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

如果您可以在给定返回 SharePoint 网址的本地 OneDrive 文件路径的情况下创建独立函数,我将非常感谢您在此处分享您的解决方案.

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

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#?

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?

解决方案

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:Usersuid41890AppDataLocalMicrosoftOneDrivesettingsBusiness1{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:DSUsersuid41890Continental AGGUIDEs - General" 2 "General" bd0c1b7c-2a1f-4492-8b1b-8e152c9e0c26

You also have this mapping in the registry ComputerHKEY_CURRENT_USERSoftwareMicrosoftOneDriveAccountsBusiness1ScopeIdToMountPointPathCache

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

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天全站免登陆