1

我尝试搜索一些主题,但没有找到问题的解决方案。有人向我解释为什么我的 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();
   }

 }
4

1 回答 1

3

ReadByte()读取一个字节!

看看这里的例子FileStream.Read()

于 2013-06-17T04:18:57.790 回答