【发布时间】:2010-12-17 01:40:42
【问题描述】:
在 Google 文档中我有一个结构:
Folder1
+------Folder1-1
+------+------File1-1-1
+------Folder1-2
+------File1-1
Folder2
我想使用 .Net google api 库将“File1-1”移动到“Folder2”(Google Data API SDK)
public static void moveFolder(string szUserName, string szPassword, string szResouceID, string szToFolderResourceID)
{
string szSouceUrl = "https://docs.google.com/feeds/default/private/full"
+ "/" + HttpContext.Current.Server.UrlEncode(szResouceID);
Uri sourceUri = new Uri(szSouceUrl);
//create a atom entry
AtomEntry atom = new AtomEntry();
atom.Id = new AtomId(szSouceUrl);
string szTargetUrl = "http://docs.google.com/feeds/default/private/full/folder%3Aroot/contents/";
if (szToFolderResourceID != "")
{
szTargetUrl = "https://docs.google.com/feeds/default/private/full"
+ "/" + HttpContext.Current.Server.UrlEncode(szToFolderResourceID)
+ "/contents"
;
}
Uri targetUri = new Uri(szTargetUrl);
DocumentsService service = new DocumentsService(SERVICENAME);
((GDataRequestFactory)service.RequestFactory).KeepAlive = false;
service.setUserCredentials(szUserName, szPassword);
service.EntrySend(targetUri, atom, GDataRequestType.Insert);
}
运行此功能后,我有:
Folder1
+------Folder1-1
+------+------File1-1-1
+------Folder1-2
+------File1-1
Folder2
+------File1-1
“File1-1”同时显示在“Folder1”和“Folder2”中,当我从一个文件夹中删除它时,它会在另一个文件夹中被删除。 (预期:“File1-1”仅在“Folder2”中显示)
会发生什么?我该如何解决这个问题?
【问题讨论】:
标签: c# .net google-code google-docs-api google-docs