c# - 使用特殊字符更新 DriveItem 会返回错误
问题描述
我正在尝试更新驱动器项的父引用,其中驱动器项的名称或包含特殊字符(%25
例如)的新父路径,并且新父项和项都在同一个组和驱动器中。
当新父母的路径包含这些字符时,我得到一个无效的请求异常。
25
当更新驱动器项目的名称包含这些字符时,我会收到“未找到项目”异常,但在从项目名称中删除后,该项目将移动到目的地。
除了这两种情况外,我的代码工作正常。
这是我尝试做的事情:
destinationPath = Uri.EscapeDataString(destinationPath);
var destination = await client
.Groups[groupId]
.Drives[driveId]
.Root
.ItemWithPath(destinationPath)
.Request()
.GetAsync();
DriveItem newItem = new DriveItem {
ParentReference = new ItemReference { Id = destination.Id }
};
sourcePath = Uri.EscapeDataString(sourcePath);
var movedItem = await client
.Groups[groupId]
.Drives[driveId]
.Root
.ItemWithPath(sourcePath)
.Request()
.GetAsync();
var result = await client
.Groups[groupId]
.Drives[driveId]
.Items[movedItem.Id]
.Request()
.UpdateAsync(newItem);
解决方案
OneDrive 不支持%
文件名或路径名(或其他几个特殊字符)。这与 Microsoft Graph 无关,OneDrive 本身(或许多文件系统)不支持它们。
从OneDrive、OneDrive for Business 和 SharePoint 中的无效文件名和文件类型:
OneDrive、OneDrive for Business on Office 365 和 SharePoint Online 中的文件和文件夹名称中不允许使用的字符:
" * : < > ? / \ |
SharePoint Server 2013 上 OneDrive for Business 的文件和文件夹名称中不允许使用的字符:
~ " # % & * : < > ? / \ { | }.
推荐阅读
- html - 对齐按钮,不管段落的长度
- java - circleci 使用 maven 构建测试 jar 并上传到 jfrog artifactory
- r - 根据前导零和尾随零将向量分组,将最大值分配给最后一项
- reactjs - 如何在 AutoComplete Material UI 的 TextField 中设置选定值
- sql - 对作为另一个选择的输出的每个表执行 count(*)
- python-3.x - 使用 XPATH 进行网页抓取并不顺利
- android - 如何将波纹添加到 Android TextView 以进行单击和 LongClick
- c - *点的动态数组在重新分配后崩溃和泄漏内存 - 为什么?
- swift - UIViewRepresentable updateUIView() 使用 .sheet() 时的奇怪行为
- yaml - 在无服务器框架中找不到导出名称 XYZ