[英]How can I update the creation and/or the last modified time of a file stored on OneDrive (Business) using the OneDrive SDK
我正在尝试更新存储在OneDrive(业务)上的文件的创建和最后修改日期。
我已经成功更新/设置了其他文件属性(或构面),但是由于某种原因,当我尝试更新日期/时间构面时,我的代码总是抛出以下异常
'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中的文件。
有谁知道为什么此代码可能会失败吗?
可能是因为:
备注
FileSystemInfo属性不适用于SharePoint或OneDrive for Business中的项目。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.