1

在 Google Document 我有一个结构:

Folder1
+------Folder1-1
+------+------File1-1-1
+------Folder1-2
+------File1-1
Folder2

我想使用 .Net google api 库(Google Data API SDK)将“File1-1”移动到“Folder2”

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”中显示)

发生什么事?我怎么解决这个问题?

4

1 回答 1

0

根据协议文档,这似乎是一个两步过程。将 File1-1 放入 Folder2,然后从 Folder1 中删除文件 File1-1。这不工作吗?

有趣的是,3.0 Python API使它成为一步过程。

于 2010-12-21T21:48:45.450 回答