我现在用VC6跟C#做C/S结构的,所以传输要压缩数据,用什么算法好?要有源代码的。

解决方案 »

  1.   

    有的,用Zlib可以进行解压和加压,效率也很高,Zlib可以到http://www.zlib.net/
    看,全免费,代码公开,不过目前在国内相关资料尚不多,
      

  2.   

    http://www.componentace.com/data/trial/zlib.NET_101.zip 直接调用它zlib.net.dll,以下代码怎么不行啊?byte[] b = System.Text.Encoding.Default.GetBytes(this.textBox1.Text);
    System.IO.MemoryStream _m = new System.IO.MemoryStream(b,0,b.Length);
    Console.WriteLine("number of bytes read: "+_m.Length);//////有数字
    zlib.ZOutputStream outZStream = new zlib.ZOutputStream(_m, zlib.zlibConst.Z_DEFAULT_COMPRESSION);
    Console.WriteLine("number of bytes read: "+outZStream.Length);// = 0 ??
    System.IO.FileStream outFileStream = new System.IO.FileStream("c:\\t.txt", System.IO.FileMode.Create);
    byte[] c = new byte[outZStream.Length];
    outFileStream.Write(b,0,b.Length);
    outFileStream.Flush();outZStream.Read(c,0,c.Length);string xx = System.Text.Encoding.Default.GetString(c,0,c.Length);
    this.textBox2.Text = xx;