6

コードビハインドとしてC#を使用してasp.netを使用しているプロジェクトでGOOGLEDOCSを使用するにはどうすればよいですか。

基本的に、いくつかのpdf、doc、dox、excelドキュメントをブラウザの読み取り専用フォームで表示する必要があります。

前もって感謝します

4

2 に答える 2

3

GoogleドキュメントにはそのためのAPIがあります。

GoogleドキュメントリストデータAPIを使用すると、クライアントアプリケーションは、Googleドキュメントに保存されているユーザーデータにプログラムでアクセスして操作できます。

それのドキュメントをチェックしてください、それはあなたがグーグルドキュメントに基づいて何かを開発するのに必要な例とすべてを持っています。

于 2009-10-14T13:37:21.873 に答える
1
using System;  
using System.IO;  
using System.Net;  
using Google.Documents;  
using Google.GData.Client;  

namespace Google  
{  
    class Program  
    {  
        private static string applicationName = "Testing";  

        static void Main(string[] args)  
        {  
            GDataCredentials credentials = new GDataCredentials("username@gmail.com", "password");  
            RequestSettings settings = new RequestSettings(applicationName, credentials);  
            settings.AutoPaging = true;  
            settings.PageSize = 100;  
            DocumentsRequest documentsRequest = new DocumentsRequest(settings);  
            Feed<document> documentFeed = documentsRequest.GetDocuments();  
            foreach (Document document in documentFeed.Entries)  
            {  
                Document.DownloadType type = Document.DownloadType.pdf;  

                Stream downloadStream = documentsRequest.Download(document, type);  

                Stream fileSaveStream = new FileStream(string.Format(@"C:\Temp\{0}.pdf", document.Title), FileMode.CreateNew);  

                if (fileSaveStream != null)  
                {  
                    int nBytes = 2048;  
                    int count = 0;  
                    Byte[] arr = new Byte[nBytes];  

                    do  
                    {  
                        count = downloadStream.Read(arr, 0, nBytes);  
                        fileSaveStream.Write(arr, 0, count);  

                    } while (count > 0);  
                    fileSaveStream.Flush();  
                    fileSaveStream.Close();  
                }  
                downloadStream.Close();  
            }  

        }  
    }  
}  
于 2013-05-31T12:58:12.590 に答える