各位大侠:
    我想请问一下,我用C#解压ZIP格式的压缩文件,现在能做到的是可以解压出来,
但是必须要生成一个文件或者文件夹来存放解压出来的文件,
如果解压后就直接打开,不生成一个解压后的文件,该怎么做呢。?

解决方案 »

  1.   


    有没有ZIP的源码,?
     
    直接操作文件流.
      

  2.   

    使用SharpZipLib,这个是开源的zip格式的解压缩
      

  3.   

    SharpZipLib,这个开源的zip格式的解压缩,这个东西解压的时候好像要把文件流重新写一遍吧
    我能不能直接查看 ZIP包里面的文件呢
      

  4.   


    using ICSharpCode.SharpZipLib.Zip;//----------------------------------
    using (ZipInputStream s = new ZipInputStream(File.OpenRead("test.zip")))
    {
    ZipEntry theEntry;
    while ((theEntry = s.GetNextEntry()) != null)
    {
    //得到文件名
    string filename = Path.GetFileName(theEntry.Name);
    //这里判断你要读取的文件
    if(filename.Equals("1.txt"))
    {
    //这里我直接使用的内存流
    using (MemoryStream ms = new MemoryStream(1024))
    {
      int size = 2048;
      byte[] data = new byte[2048];
      while (true)
      {
          size = s.Read(data, 0, data.Length);
          if (size > 0)
          {
            ms.Write(data, 0, size);
          }
          else
          {
            break;
          }
      }
      ms.Seek(0, SeekOrigin.Begin);
    }
    }
    }
    }