更新具有特殊字符的 DriveItem returns 错误

Updating a DriveItem with special characters returns error

我正在尝试更新驱动器项的 parent 引用,其中驱动器项的名称或新的 parent 路径包含特殊字符(例如 %25),并且两者新 parent 和项目在同一组和驱动器中。

除了这两种情况,我的代码工作正常。

这是我尝试做的事情:

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 本身(或与此相关的许多文件系统)不支持它们。

来自Invalid file names and file types in OneDrive, OneDrive for Business, and SharePoint

Characters that aren't allowed in file and folder names in OneDrive, OneDrive for Business on Office 365, and SharePoint Online: " * : < > ? / \ |

Characters that aren't allowed in file and folder names in OneDrive for Business on SharePoint Server 2013: ~ " # % & * : < > ? / \ { | }.