使用api问题将文件或文件夹移动到google文档中的不同文件夹

发布于 2024-10-08 01:10:50 字数 1794 浏览 0 评论 0原文

在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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素染倾城色 2024-10-15 01:10:50

根据协议文档,它似乎是两个步骤过程。将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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文