如何添加“父参考项目”到“文件项目列表”使用c# [英] how to add "Parent Reference item" to "File item List" using c#
问题描述
我在这里试图获取谷歌驱动器项目&动态添加我自己的项目以供临时使用。
IList< File> Files = new List< File>();
FilesResource.ListRequest list = service.Files.List();
FileList filesFeed = list.Execute();
ParentReference pitem = new ParentReference();
文件fileitem = 新文件();
fileitem.Id = RootId;
fileitem.Title = MainDrive;
pitem.Id = null ;
pitem.IsRoot = true ;
fileitem.Parents.Add(pitem);
Files.Add(fileitem);
在上面的代码中我可以添加谷歌驱动文件项目加上我的拥有fileitem到文件列表。
要获取父ID,我必须编写以下代码
(x => x.Files [ 0 ]。父[ 0 ]。Id)
但是对于我添加的项目fileitem.Parents本身为空,那我该如何添加父项? id等于null(pitem.Id = null;)??抛出异常。
当我试图将父referance添加到List时,我抛出对象引用未设置为对象的实例。错误
有人可以帮我PLZ ......: - (
我知道了......
fileitem.Parents = new List< parentreference>(){new ParentReference(){Id = _parent}};
来自以下链接:
http://www.daimto.com/google-drive-api-c-upload / [ ^ ]
Hi,here i'm trying to fetch google drive items & adding my own item dynamically for temporary use.
IList<File> Files = new List<File>();
FilesResource.ListRequest list = service.Files.List();
FileList filesFeed = list.Execute();
ParentReference pitem = new ParentReference();
File fileitem = new File();
fileitem.Id = RootId;
fileitem.Title = "MainDrive";
pitem.Id = null;
pitem.IsRoot = true;
fileitem.Parents.Add(pitem);
Files.Add(fileitem);
In the above code i'm able to add google drive file items plus my own "fileitem" to "Files" List.
To fetch the parent id i have to write the below code
(x=>x.Files[0].Parent[0].Id)
But for the item which i added has "fileitem.Parents" itself is null,then how can i add parent id equal null(pitem.Id = null;)??Throwing exception.
When i'm trying to add parent referance to List,i'ts throwing "Object reference not set to an instance of an object." error
Can some one help me plz... :-(
I got it...
fileitem.Parents = new List<parentreference>() { new ParentReference() { Id = _parent } };
from the below link:
http://www.daimto.com/google-drive-api-c-upload/[^]
这篇关于如何添加“父参考项目”到“文件项目列表”使用c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!