简体   繁体   English

尝试将 zip 文件发送到导航器时出错

[英]Error trying to send zip file to navigator

I'm trying to send a zip file to navigator in ASP.NET Visual Basic, I do the following:我正在尝试将 zip 文件发送到 ASP.NET Visual Basic 中的导航器,我执行以下操作:

Response.Clear()
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName)
Response.ContentType = "application/zip"
Response.WriteFile(fullPath)
Response.End()

I get this strange characters我得到这个奇怪的字符

在此处输入图像描述

How can I send the zip to navigator?如何将 zip 发送到导航器?

A zip file is NOT a text file. zip 文件不是文本文件。 Don't treat it like a text file.不要将其视为文本文件。 Don't try viewing it like a text file.不要尝试像查看文本文件一样查看它。

Rather, a ZIP file is a binary file format.相反,ZIP 文件是二进制文件格式。 It is a container (also often called an archive) that contains compressed files.它是一个包含压缩文件的容器(通常也称为存档)。 What you see there in your screenshot is just the binary data of the ZIP file.您在屏幕截图中看到的只是 ZIP 文件的二进制数据。 Binary data which whatever viewer you used tried to interpret as character codes -- which of course will not yield any sensible result, because a ZIP file is not a text file.您使用的任何查看器都试图将二进制数据解释为字符代码——这当然不会产生任何合理的结果,因为 ZIP 文件不是文本文件。 It's not.它不是。

If you want to get your hands on the files compressed within the ZIP file, you need to uncompress ("unpack") the ZIP file.如果您想获得 ZIP 文件中压缩的文件,您需要解压缩(“解包”)ZIP 文件。

By the way, i can see that the compressed file within the ZIP file is presumably a PDF file.顺便说一下,我可以看到 ZIP 文件中的压缩文件大概是一个 PDF 文件。 Which is also not a text file, but requires a PDF reader/viewer to display/render it (after it has been unpacked from the ZIP file, obviously...).这也不是一个文本文件,但需要一个 PDF 阅读器/查看器来显示/呈现它(在它从 ZIP 文件中解压缩后,显然......)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM