问题标签 [dotnetzip]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
asp.net - Connection being closed when trying to send large zip file
What I'm trying to accomplish is to allow users to download multiple files from silverlight application. To do this I've decided to use DotNetZip
library and ASP.NET
handler that will take care of getting all files from database and sending them to client. It seemed like good idea and easy to implement. I've created simple handler, wrote all the code required and everything worked.
However for some reason, when I create zip file with many files, there is an issue. The remote host closed the connection. The error code is 0x800704CD.
exception is being thrown when I try to write data to Response
.
As you can see I'm creating MemoryStream
and sending small pieces of data to Response
, as I've seen it shown as solution to similar problems, but this didn't help. Saving Zip
file directly to Response
is giving me exactly the same error.
BufferOutput
property is set to False
so it would start download immediately, but changing it to True
does not change anything.
The zip
file I'm trying to send is about 248 megabytes, and this gives me error. When I remove some elements and zip
file is around 220 megabytes, everything seems to work fine.
Does anyone knows, what might be the reason for this behavior? How can I fix this, so sending zip files will not give me this error?
c# - IonicZip/DotNetZip 无法访问已关闭的文件。context.Response.OutputStream
我有一个*.ashx
带有此代码的(处理程序):
我使用最新版本的http://dotnetzip.codeplex.com/File.ReadAllBytes
有人可以向我解释一下,
为什么StreamReader
保存到OutputStream
. 异常消息是无法访问已关闭的文件
c# - 无法使用 DotNetZip 1.9 从 HttpInputStream 读取 zip 文件
我正在尝试使用 DotNetZip 1.9 在 Asp.Net MVC 3 中读取上传的 zip 文件。我已经验证我收到的 HttpPostedFileBase 对象没问题。我可以将它保存到磁盘然后解压缩。但是,首先保存到磁盘似乎很浪费,因为我应该能够直接从内存中解压缩。
从 MSDN 中,HttpPostedFileBase.InputStream 属性“获取指向上传文件的 Stream 对象以准备读取文件的内容”。
根据 DetNetZip 参考资料,ZipFile.Read() 可以接受 Stream 对象。所以我试了一下,DotNetZip 抛出了 BadReadException。我附上了显示问题的屏幕截图。
从 HttpInputStream 解压的问题
InputStream 的值,Length 与上传的 zip 文件的值匹配
帮助任何人?谢谢
c# - DotNetZip 流式传输
我正在尝试压缩一堆文件并通过流使数据可用。
我想保持内存占用尽可能小。
我的想法是实现一个 Stream,其中我有一堆 FileStream 对象作为数据成员。当我的 Stream 上的 Read 方法被调用时,我会从我的一个文件流中读取一些数据,并使用 ZipOutputStream 实例将压缩数据写入临时存储流,然后我会将读取请求转发到该临时存储流。
这个临时存储流只是一个字节队列。随着这些字节被移动到缓冲区中(通过调用读取),它们将从队列中删除。这样,我只会存储尚未读取的字节。
不幸的是,似乎当我处理 ZipOutputStream 时,它需要写入随机文件位置才能创建有效的 zip 文件。这将阻止我使用我的“转瞬即逝的数据”解决方案。
希望这一切都清楚:)
在创建 zip 文件时,还有其他方法可以最大限度地减少内存占用吗?请帮忙!
谢谢!
c# - 使用 DotNetZip 创建 Zip 文件时出错:存档意外结束
我有一种方法可以使用 DotNetZip 压缩一个或多个文件,并且它一直在正常工作。我今天第一次收到错误,它似乎与存档的总大小有关。使用相同的 60mb .tiff 图像,我会添加一些额外的副本,测试,重复。它工作正常,直到添加了大约 10 张图像,然后,当我使用 WinRar 打开 Zip 文件时,我会收到“存档意外结束”错误。以这种方式进行测试,我相信我已经排除了与我的代码或文件有关的问题(损坏或其他东西)。代码没有错误,只有WinRar。当我打开 Zip 文件时,只显示一个大小为“0”的文件。因此,似乎达到了某种大小限制,并且不允许创建存档。我只是不知道它是哪个限制。
dotnetzip - .NET ZipPackage 与 DotNetZip 在获取条目时的流
我在 .NET 中使用 ZipPackage 类已经有一段时间了,我真的很喜欢它具有的简单直观的 API。从条目中读取时,我执行 entry.GetStream() 并从此流中读取。写入/更新条目时,我执行 entry.GetStream(FileAccess.ReadWrite) 并写入此流。非常简单和有用,因为我可以将读/写交给不知道 Stream 最初来自哪里的其他代码。
现在,由于 ZipPackage-API 不包含对 LastModified 等条目属性的支持,我一直在研究其他 zip-api,例如 DotNetZip。但是我对如何使用它有点困惑。例如,当想从一个条目中读取数据时,我首先必须将整个条目提取到一个 MemoryStream 中,寻找到开头并将这个流移交给我的其他代码。并且要写入一个条目,我必须输入一个 ZipEntry 本身可以读取的流。这对我来说似乎很倒退。我是否以错误的方式使用此 API?
ZipEntry 是否可以直接从存储文件的磁盘传送文件并在读者阅读时提取文件?真的需要先完全提取到内存中吗?我不是专家,但对我来说似乎是错误的。
c# - 如何使用 .NET 删除 Zip 文件中的目录?
如何删除 .zip 中的目录及其中的所有文件(最好使用 DotNetZip)?
现在我正在浏览 zip 中的所有文件,但它不起作用:
有没有更好的方法,如果没有,我将如何进行这项工作?
c# - Ionic Zip:从 byte[] 创建 Zip 文件
Ionic zip 允许我将现有文件添加到 zip 对象并创建一个 zip 文件。但考虑到我正在从创建的 zip 文件中读取这些字节 [] 并通过服务器发送,我需要再次从该字节 [] 创建 zip 文件以将 zip 存储在服务器上。我该如何做到这一点?
我正在使用 C#。
c# - 尝试使用 DotNetZip 提取时出错
我有一个程序可以DotNetZip
在下载完成后解压缩下载的文件。我从 .txt 文件中获取保存路径,因为它必须被提取到文件夹系统中的特定文件夹中。没有特定保存文件夹的文件只有一个文件夹。
该程序运行良好,但有时我会收到一条错误消息:
部分路径找不到!
bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) bei System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity) bei System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity) bei System.IO.Directory.CreateDirectory(String path) bei Ionic.Zip.ZipEntry.ValidateOutput(String basedir, Stream outstream, String& outFileName) bei Ionic.Zip.ZipEntry.InternalExtract(String baseDir, Stream outstream, String password) bei Ionic.Zip.ZipEntry.Extract(String baseDirectory, ExtractExistingFileAction extractExistingFile) bei dvw002.Form1.backgroundWorker1_DoWork(Object sender, DoWorkEventArgs e)
我不知道为什么会这样,因为 95% 的文件被正常提取,并且路径存在......
c# - ZipFile 对象上的 Dup 键添加错误
我试图弄清楚如何首先检查
在遍历集合中的每个文件并尝试将其添加到 ZipFile 集合中的循环中,我得到了:
ZipFile 类型来自Ionic.Zip.dll
问题是AddItem
错误出来了,我得到一个具有相同密钥的项目已经被添加。因此,例如,最后它会尝试添加之前已在此 zip 字典中添加的密钥:
"C:\www\files\233272\Exercise Files\SampleCode\Original\MyTest.cs"
我无法检查 dup 是否正常工作……它仍然尝试在循环中添加两次。
在尝试添加之前如何检查任何文件 [0]?如果我什至可以为此使用 LINQ,我尝试LINQ .Any()
了但无法获得正确的语法。
我试过了,但我在语法上没有这样做:
也试过
也试过