我有一行代码可以读取Google云端硬盘中PDF的字节,以供其他功能稍后使用。此行一直有效,直到它遇到名为so:
的文件1234567_012368547-98884 Street Lane Test.pdf
我已经尝试在String变量和String文字中传递它,但像这样的文件总是会创建以下FileNotFoundException消息:
'C:\ Users \ JimJam \ Documents \ Project \ GoogleDriveProject \ GDriveDownload \ bin \ Debug \ 1234567_012368547-98884 Street Lane Test.pdf'。
这没有任何意义,因为它假设是在GDrive文件夹中查找,而不是我的本地项目文件夹,它对于完全相同的Google云端硬盘文件夹中的所有其他文件都是正确的。
Dim file As Byte() = System.IO.File.ReadAllBytes("1234567_012368547-98884 Street Lane Test.pdf")
答案 0 :(得分:0)
正如jmcilhinney和Danny James指出的那样,System.IO.File不是获取流的方式,因为它希望文件存储在我的机器本地。相反,我使用Google API使用以下逻辑:
Dim Service = New DriveService(New BaseClientService.Initializer() With
{.HttpClientInitializer = MyCredentials, .ApplicationName =
"ApplicationName")})
Dim fileStream = Service.HttpClient.GetStreamAsync(downloadURL)
Dim streamResult = fileStream.Result