从gdrive下载的文件已损坏

时间:2017-02-14 21:43:15

标签: c# google-drive-api

从gdrive下载文件时遇到问题

我正在使用此代码

 DriveService service = new DriveService();

            var Stream = service.HttpClient.GetStreamAsync("https://drive.google.com/open?id=blablabla");
            var result = Stream.Result;
            using (var fileStream = System.IO.File.Create("MyFile.exe"))
            {
                result.CopyTo(fileStream);
            }

但我在MyFile.exe中的大小为103kB,它有800 kB。

我怀疑我没有得到正确的下载网址,因为我右键单击要下载的文件并获取此格式的可共享链接:https://drive.google.com/open?id=blablaid

1 个答案:

答案 0 :(得分:1)

根据www.labnol.org/internet/direct-links-for-google-drive/28356/,Google云端硬盘下载链接为https://docs.google.com/uc?export=download&id=[FILE_ID]

否则,您还可以查看Google云端硬盘REST API(developers.google.com/drive/v3/web/manage-downloads)。