我尝试搜索一些主题,但没有找到问题的解决方案。有人向我解释为什么我的 txt 是空的?
this.Response.Clear();
this.Response.ContentType = "application/x-zip-compressed";
this.Response.AppendHeader("content-disposition", "attachment; filename=Outro.zip");
System.IO.FileStream reader = File.OpenRead(@"C:\Teste\Teste.txt");
byte[] bytes = new byte[reader.ReadByte()];
using (ZipFile zipFile = new ZipFile())
{
using (MemoryStream stream = new MemoryStream())
{
stream.Seek(0, SeekOrigin.Begin);
stream.Read(bytes, 0, bytes.Length);
zipFile.AddEntry("Arquivo.txt", stream);
zipFile.Save(this.Response.OutputStream);
}
zipFile.Dispose();
}
}