2012-02-06 7 views
2

私はGoogleドキュメントにフォルダ内のすべての文書を取得する方法

public DocumentsFeed GetDocs() 
    { 
     DocumentsListQuery query = new DocumentsListQuery(); 
     DocumentsFeed feed = service.Query(query); 
     return feed; 
    } 

を使用してGoogleドキュメント内のすべてのドキュメントを取得することができますしかし、どのように、私は特定のフォルダ内の文書を入手できますか?私は、フォルダのリストを発見し、ツリービューでフォルダを作成することを望む。フォルダを選択すると、そのフォルダ内の文書を取得します。フォルダを取得するには

は、私がサービスのために

public DocumentsFeed GetFolders() 
    { 
     FolderQuery query = new FolderQuery("root"); //http://docs.google.com/feeds/documents/private/full 
     DocumentsFeed feed = service.Query(query); 
     return feed; 

    } 

を使用しています、私はprivate DocumentsService service;

誰かが助けることができますを使用していますか?

答えて

1

APIを使用して別の男は、彼がそれをしない方法を説明しています

var docService = new DocumentsService("company-app-version"); 
docService.setUserCredentials("username", "password"); 
using Google.GData.Client; 
using Google.GData.Extensions; 
using Google.GData.Documents; 

// snipped method declaration etc 

var docService = new DocumentsService("company-app-version"); 
docService.setUserCredentials("username", "password"); 

var folderList = docService.Query(new FolderQuery()); 
var fLinks = folderList.Entries.Select(e => 
new 
{ 
    // note how to get the document Id of the folder 
    Id = DocumentsListQuery.DocumentId(e.Id.AbsoluteUri), 
    Name = e.Title.Text 
}); 

foreach (var folder in fLinks) 
{ 
    Console.WriteLine("Folder {0}", folder.Name); 

    var fileList = docService.Query(
     new SpreadsheetQuery() 
     { 
      // setting the base address to the folder's URI restricts your results 
      BaseAddress = DocumentsListQuery.folderBaseUri + folder.Id 
     }); 

    foreach (var file in fileList.Entries) 
    { 
     Console.WriteLine(" - {0}", file.Title.Text); 
    } 
} 

出典:resourceIDを使用

の代わりに、フォルダの名前を入力し、: http://jtnlex.com/blog/2010/06/09/google-docs-api-get-all-spreadsheetsdocs-in-a-folder/

+0

これはすでに見ました。しかし、これは私が探しているものではありません。私が求めているものを手に入れられますか? – Kangkan

+1

あなたは何を求めていますか?これはあなたの質問に答えてくれそうです。 – ptomato

+0

答えはOPにマッチしません。それを注意深く読んでください。 – Kangkan

0

はここに方法ですフォルダのquery = new FolderQuery(FolderEntry.ResourceId);

しかし、まずすべてのドキュメントを取得する必要がありますtsを使用してフォルダを表示することができます:query.ShowFolders = true;、これはrootのドキュメントのresourceIdと、 のフォルダを取得する方法です。

希望すると便利です。