问题
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
回答1:
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);
来源:https://stackoverflow.com/questions/4780743/upload-and-replace-file-in-given-folder-on-google-docs-using-net-api