的內容我已經使用https://developers.google.com/drive/v3/web/manage-downloads,我有一個代碼的工作副本,可以從Google驅動器下載具有權限訪問的文件。如何閱讀谷歌文檔
有什麼辦法,我可以閱讀Word文檔
示例代碼下載文件(使用的GDrive - 新建 - 新文件創建):
private static void DownloadFile(string fileId, DriveService driveService)
{
var request = driveService.Files.Export(fileId, "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
var stream = new System.IO.MemoryStream();
// Add a handler which will be notified on progress changes.
// It will notify on each chunk download and when the
// download is completed or failed.
request.MediaDownloader.ProgressChanged +=
(IDownloadProgress progress) =>
{
switch (progress.Status)
{
case DownloadStatus.Downloading:
{
Console.WriteLine(progress.BytesDownloaded);
break;
}
case DownloadStatus.Completed:
{
Console.WriteLine("Download complete.");
break;
}
case DownloadStatus.Failed:
{
Console.WriteLine("Download failed.");
break;
}
}
};
request.Download(stream);
using (FileStream file = new FileStream("file.doc", FileMode.Create, FileAccess.Write))
{
stream.WriteTo(file);
}
}
感謝您的快速響應,但我想直接從驅動器中讀取文檔並下載它。 – user1621791