上传并使用.NET API定文件夹中替换谷歌文档文件文件、上传、文档、夹中

2023-09-04 06:25:27 作者:星河不入眼

我试图将文件上载到使用.NET客户端谷歌-API给定文件夹。我可以用这个做的:

 服务=新DocumentsService(SRDUploader);
DocumentEntry lastUploadEntry = service.UploadDocument(文件,NULL);
 

这工作得很好,但我需要更多的东西:

如何指定目标文件夹(试图用\我的文件夹\ file.txt的为谢胜利ARG)? 如何指定我wan't覆盖现有文件?

我使用版本2 版本的.NET客户端API。也许有另一个版本?

感谢您的帮助

Larsi

解决方案

  DocumentEntry父= ....;
DocumentEntry删除= ......;

deleting.Delete();

串料=的String.Format(DocumentsListQuery.foldersUriTemplate,parent.ResourceId);
// http://docs.google.com/feeds/default/private/full/{0}/contents

VAR的结果= service.Insert(新的URI(饲料),文件流,fileExtension,文件名);
 

取代谷歌,1秒内搜不到你要的文件算我输

I'm trying to upload a file to a given folder using the .net client for google-api. I can do this using:

service = new DocumentsService("SRDUploader");
DocumentEntry lastUploadEntry = service.UploadDocument(file, null );

That works fine, but I need to more things:

How can I specifying the destination folder (tried with "\My folder\file.txt" as secound arg)? How can I specify that I wan't to overwrite the existing file?

I'm using version 2 version of the .net client api. Maybe there's another version?

Thanks for any help

Larsi

解决方案

DocumentEntry parent = ....;
DocumentEntry deleting = ....;

deleting.Delete();

string feed = string.Format(DocumentsListQuery.foldersUriTemplate, parent.ResourceId);
// http://docs.google.com/feeds/default/private/full/{0}/contents

var result = service.Insert(new Uri(feed), fileStream, fileExtension, fileName);