0

我正在从我的桌面应用程序的 Web API 获取 FileContentResult。

{
    "fileContents": "JVBERi0xLjMNCjEgMCBvYmoNNzQ3Ng0KJSVFT0Y=",
    "contentType": "application/octet-stream",
    "fileDownloadName": "",
    "lastModified": null,
    "entityTag": null,
    "enableRangeProcessing": false
}

需要知道如何下载文件?

我尝试使用 Json.Net 进行反序列化,但它会抛出错误“未知对象类型!系统.字节'

4

1 回答 1

0

我尝试使用 Newtonsoft.Json 而不是 Json.Net,使用下面的代码我能够下载该文件。

Dim fcr As System.Web.Mvc.FileContentResult
fcr = Newtonsoft.Json.JsonConvert.DeserializeObject(Of System.Web.Mvc.FileContentResult)(json_string)
File.WriteAllBytes("e:\test.pdf", fcr.FileContents)
于 2018-12-25T11:23:55.580 回答