gpt4 book ai didi

c# - .NET OneDrive Api 创建文件夹问题

转载 作者:太空宇宙 更新时间:2023-11-03 12:51:46 26 4
gpt4 key购买 nike

我正在尝试使用我的 Apps/[appName] 文件夹创建一个文件夹。

代码如下:

var request = OneDriveService.Drive.Special.AppRoot.Request().CreateAsync(new Item()
{
Name = name,
});

request.Wait();

但我不断收到错误消息:

{Code: invalidRequest Throw site: 1c0e.2859 Message: The name in the provided oneDrive.item does not match the name in the URL }

谁知道这是什么意思?

最佳答案

我编写了这段代码,而不是 CreateAsync:

        try
{
var documentsBuilder = this.oneDriveClient.Drive.Root.ItemWithPath("Documents");
var children = await documentsBuilder.Children.Request().GetAsync();
// try to find existing folder
var folder = children.FirstOrDefault(c => c.Name.Equals("Some folder"));

// create it if it doesn't exist
if (folder == null)
{
var newFolder = new Item { Name = "Some folder", Folder = new Folder() };
await documentsBuilder.Children.Request().AddAsync(newFolder);
}
}
catch (OneDriveException exception)
{
throw;
}

关于c# - .NET OneDrive Api 创建文件夹问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35281668/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com