使用api问题将文件或文件夹移动到google文档中的不同文件夹
在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”中)
会发生什么?我该如何解决这个问题?
In Google Document i have a struct:
Folder1
+------Folder1-1
+------+------File1-1-1
+------Folder1-2
+------File1-1
Folder2
I want to move "File1-1" to "Folder2" using .Net google api library(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);
}
After run this function i have:
Folder1
+------Folder1-1
+------+------File1-1-1
+------Folder1-2
+------File1-1
Folder2
+------File1-1
"File1-1" display in both "Folder1" and "Folder2", and when i delete it from a folder it will be deleted in another folder. (expect: "File1-1" display only in "Folder2")
What happen? How can i solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据协议文档,它似乎是两个步骤过程。将File1-1放入Folder2中,然后从Folder1中删除文件File1-1。这不行吗?
有趣的是,3.0 Python API 使其一步完成。
According to the protocol docs it seems to be a two step process. Put File1-1 into Folder2, then delete file File1-1 from Folder1. Is this not working?
Interestingly the 3.0 Python API makes it one step process.