C# 无法下载应用程序/vnd.google-apps.site文档

C# 无法下载应用程序/vnd.google-apps.site文档,c#,google-drive-api,C#,Google Drive Api,我在下载vnd.google-apps.site文档时收到此错误消息: public async void Test() { var request = service.Files.Export("YourFileId", "text/html"); string result = await request.ExecuteAsync(); MessageBox.Show(result); } Google.api.Requests.RequestError 只能下载包

我在下载vnd.google-apps.site文档时收到此错误消息:

public async void Test()
{
    var request = service.Files.Export("YourFileId", "text/html");
    string result = await request.ExecuteAsync();
    MessageBox.Show(result);
}
Google.api.Requests.RequestError 只能下载包含二进制内容的文件。使用导出Google文档文件。[403] 错误[ Message[只能下载包含二进制内容的文件。使用Google Docs文件导出。]位置[alt-参数]原因[fileNotDownloadable]域[global] ]

使用以下代码:

        try
        {
            var request = driveService.Files.Get(fileId);
            var result = await request.DownloadAsync(outstream);
            return result;
        }
        catch (Exception e)
        {
            Console.WriteLine("DownloadFile An error occurred: " + e.Message);
        }
我犯了这个错误

Google.api.Requests.RequestError 不支持请求的转换。[400] 错误[ 消息[不支持请求的转换。]位置[convertTo-参数]原因[badRequest]域[global] ]

使用导出方法时:

        try
        {
            //tried mimeType with: text/html and application/vnd.google-apps.site
            //**it works if using text/plain**
            var request = service.Files.Export(fileId, mimeType);
            var result = await request.DownloadAsync(outstream);
            return result;
        }
        catch (Exception e)
        {
            Console.WriteLine("ExportFile An error occurred: " + e.Message);
        }

如何下载站点文件?谢谢。

这是导出文档的方法:

public async void Test()
{
    var request = service.Files.Export("YourFileId", "text/html");
    string result = await request.ExecuteAsync();
    MessageBox.Show(result);
}

如您所见,您只需将
request.downloadsync(outstream)
更改为
request.ExecuteAsync()
。您可以从我的评论中获得可能的mimetype。

如例外情况中所述,您将无法下载文档。您需要将文档导出到您想要的文件中。我尝试使用该文件,它对我的文档起作用,我可以将其导出到例如text/html。因此,您得到了文档中的内容-感谢您的回复。是的,但我希望像word文档一样导出站点页面。我仍然不明白你想做什么,你能解释一下吗?发布一个文件示例,并向我们展示您想要得到的结果。