Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#-Microsoft Graph API-对DriveItem的权限不起作用_C#_Microsoft Graph Api_Microsoft Graph Sdks - Fatal编程技术网

c#-Microsoft Graph API-对DriveItem的权限不起作用

c#-Microsoft Graph API-对DriveItem的权限不起作用,c#,microsoft-graph-api,microsoft-graph-sdks,C#,Microsoft Graph Api,Microsoft Graph Sdks,我正在使用Microsoft Graph将DriveItem创建为文件夹,并尝试将权限设置为“替换”。我尝试了以下方法: var driveItem = new DriveItem { Name = Customer_Name.Text + Customer_LName.Text, Folder = new Folder { }, AdditionalData = new Dictionary<string, object>() {

我正在使用Microsoft Graph将
DriveItem
创建为
文件夹
,并尝试将权限设置为“替换”。我尝试了以下方法:

var driveItem = new DriveItem
{
    Name = Customer_Name.Text + Customer_LName.Text,
    Folder = new Folder { },
    AdditionalData = new Dictionary<string, object>()
    { 
        { "@microsoft.graph.conflictBehavior", "replace" }
    }
};

var newFolder = await App.GraphClient
    .Me
    .Drive
    .Items["item.ID"]
    .Children
    .Request()
    .AddAsync(driveItem);
var driveItem=新的driveItem
{
Name=Customer\u Name.Text+Customer\u LName.Text,
Folder=新文件夹{},
AdditionalData=新字典()
{ 
{“@microsoft.graph.conflictBehavior”,“replace”}
}
};
var newFolder=wait App.GraphClient
我
.开车
.Items[“item.ID”]
儿童
.Request()
.AddAsync(驱动项);
第一次运行代码时,一切正常,但第二次出现以下错误:

无法获取文件夹的内容


这太奇怪了…我做错了什么?或者有没有办法通过名称获取驱动项来获取id?

文档在这一点上并不清楚,但是
“@microsoft.graph.conflictBehavior”:“replace”
不是文件夹的有效选项。如果您认为“代码> >替换<代码>的含义将在这里,则可能导致任何子文件或文件夹被无意地擦除。 至于使用路径而不是id,可以通过将
Item[“id”]
替换为
ItemWithPath(“Item/with/path”)

您可以使用以下方法检索它的子项:

var childItems = await App.GraphClient
    .Me
    .Drive
    .Root
    .ItemWithPath("folder name")
    .Children
    .Request()
    .GetAsync();
var childItems = await App.GraphClient
    .Me
    .Drive
    .Root
    .ItemWithPath("folder name")
    .Children
    .Request()
    .GetAsync();