>>>都是存入本地文件的,请问能在内存里面,保存成字符串吗?your 压缩 class probably takes a Stream object, look into System.IO.MemoryStream

解决方案 »

  1.   

    可以的.本人的ZIP算法就做到了这点.当然,你想啊,任何压缩都是读数据,在内存中压缩,然后存到文件中
      

  2.   

    我写了一段测试代码,但是ss返回内容为空,请问哪里错了。
    public string HelloWorld()
    {
    //int i=0;
    string temp="11111";
    string temp1="";
    for(int i=0;i<1000;i++)
    {
    temp1=temp1+temp;
    }
    byte [] ss=System.Text.UTF8Encoding.UTF8.GetBytes(temp1);
    DeCompress(ref ss);
    int j=ss.Length;
    return "Hello World";
    } /// <summary>
    /// 采用Zip解压缩byte数组
    /// </summary>
    /// <param name="mybyte">byte数组</param>
    public static void DeCompress(ref byte[] mybyte)
    {
    //byte数组转化成输入流
    //ICSharpCode.SharpZipLib.Zip.ZipInputStream.
    Stream inputStream = new MemoryStream();
    inputStream.Seek(0, SeekOrigin.Begin);
    inputStream.Write(mybyte, 0, mybyte.Length);

    Stream outputStream = new MemoryStream();
    //初始化指针
    outputStream.Seek(0, SeekOrigin.Begin);
    inputStream.Seek(0, SeekOrigin.Begin);
    //实例化解压程序
    ZipInputStream s = new ZipInputStream(inputStream);
    if(1==1)
    {
    int size = 2048;
    byte[] data = new byte[2048];
    while (true) 
    {
    size = s.Read(data, 0, data.Length);
    if (size > 0) 
    {
    //把字节数组分步写到流中
    outputStream.Write(data, 0, size);
    }
    else
    {
    break;
    }
    }
    s.Close();
    //把流写入到byte数组中去
    int iLength = (int)outputStream.Length;
    mybyte = new Byte[iLength];
    outputStream.Seek(0, SeekOrigin.Begin);
    outputStream.Read(mybyte, 0, mybyte.Length);
    }
    outputStream.Close();
    }
    }
      

  3.   

    原函数条件不是1=1,而是if(s.GetNextEntry() != null)
    但是我发现到这步就出错,所以就暂时改成1=1