如何使用 OneDrive SDK 更新存储在 OneDrive (Business) 上的文件的创建 and/or 最后修改时间
How can I update the creation and/or the last modified time of a file stored on OneDrive (Business) using the OneDrive SDK
我正在尝试更新存储在 OneDrive (Business) 上的文件的创建日期和上次修改日期。
我已经成功 updated/set 其他文件属性(或方面),但是,由于某种原因,当我尝试更新 date/time 方面时,我的代码总是抛出以下异常
'Microsoft.OneDrive.Sdk.OneDriveException' with Error = {Code: invalidRequest Message: The request is malformed or incorrect.}
代码相对简单(取自 SDK 示例)
var remoteFileId = "0153C2VFI2EGGLRJXTANFLXLWP6UJXCFW3";
var newItemFacets = new Item
{
FileSystemInfo = new FileSystemInfo
{
CreatedDateTime = DateTimeOffset.Now - TimeSpan.FromDays(1),
LastModifiedDateTime = DateTimeOffset.Now
}
};
await _oneDriveClient
.Drive
.Items[remoteFileId]
.Request()
.UpdateAsync(newItemFacets);
remoteFileId 的值当然是特定于存储在我的 OneDrive 上的文件。
有人知道为什么这段代码可能会失败吗?
可能是因为这个:
Remarks
The FileSystemInfo property is not available for items in SharePoint
or OneDrive for Business.
我正在尝试更新存储在 OneDrive (Business) 上的文件的创建日期和上次修改日期。
我已经成功 updated/set 其他文件属性(或方面),但是,由于某种原因,当我尝试更新 date/time 方面时,我的代码总是抛出以下异常
'Microsoft.OneDrive.Sdk.OneDriveException' with Error = {Code: invalidRequest Message: The request is malformed or incorrect.}
代码相对简单(取自 SDK 示例)
var remoteFileId = "0153C2VFI2EGGLRJXTANFLXLWP6UJXCFW3";
var newItemFacets = new Item
{
FileSystemInfo = new FileSystemInfo
{
CreatedDateTime = DateTimeOffset.Now - TimeSpan.FromDays(1),
LastModifiedDateTime = DateTimeOffset.Now
}
};
await _oneDriveClient
.Drive
.Items[remoteFileId]
.Request()
.UpdateAsync(newItemFacets);
remoteFileId 的值当然是特定于存储在我的 OneDrive 上的文件。
有人知道为什么这段代码可能会失败吗?
可能是因为这个:
Remarks
The FileSystemInfo property is not available for items in SharePoint or OneDrive for Business.