Move file or folder to a different folder in google document using api problem

Posted by Minh Nguyen on Stack Overflow See other posts from Stack Overflow or by Minh Nguyen
Published on 2010-12-17T01:40:42Z Indexed on 2010/12/21 21:54 UTC
Read the original article Hit count: 258

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET