我正在尝试使用 vb.net 应用程序从 Google 驱动器下载 csv 文件。这多年来一直运行良好,但今天,当我尝试使用该应用程序下载时,我收到一个 csv 文件,其中仅包含以下消息:“Google 云端硬盘 - 超出配额:您目前无法查看或下载此文件。太许多用户最近查看或下载了此文件...“但是该错误消息可能不准确,因为当我尝试将相同的网址粘贴到浏览器中时,我希望毫无问题地下载 1.3 MB csv 文件。
我尝试指定一个 User-Agent 标头来告诉 Google 我正在使用浏览器,但没有任何改进。
知道为什么可以从浏览器下载,但不能从 WebClient 下载吗?谢谢!
我的代码如下:
Private Sub UpdateCatalog()
Dim _WebClient As New System.Net.WebClient()
_WebClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
Dim url As String
url = "https://drive.google.com/uc?export=download&id=1HDRnj41YBWpMioLPwAFiLlK4SK8NV72C"
' Check if the folder already exists; if not, create it
If Not My.Computer.FileSystem.DirectoryExists(My.Settings.CatalogFolder) Then
Try
My.Computer.FileSystem.CreateDirectory(My.Settings.CatalogFolder)
Catch Ex As Exception
MsgBox("Could not create a folder to store the catalog file." & vbCr & Ex.Message,, "Folder Creation Error")
Exit Sub
End Try
End If
' Check if the catalog file already exists; if so, delete it
If My.Computer.FileSystem.FileExists(My.Settings.CatalogFile) Then My.Computer.FileSystem.DeleteFile(My.Settings.CatalogFile)
' Download the new file
Try
_WebClient.DownloadFile(url, My.Settings.CatalogFile)
Catch ex As Exception
MsgBox("Failed to download catalog file from Environment Canada." & vbCr & ex.Message, "Download Failure")
End Try
End Sub
这与代码无关。我在 Linux 中从 Firefox 下载文件时遇到同样的问题,但可以在 Windows 中使用 Chrome 下载。问题是昨天或今天开始的。