C# DeflateStream压缩操作

好苦恼啊!为什么输出是0字节?!
从zlib到deflate弄一晚上了,求大神!

 try
            {
                FileStream input = new FileStream(@"before.txt", FileMode.Open, FileAccess.Read, FileShare.Read);//原数据流
                FileStream output = new FileStream(@"after.bin", FileMode.OpenOrCreate, FileAccess.Write);      //输出数据流
                DeflateStream ds = new DeflateStream(output, CompressionMode.Compress);
                long bufferSize = input.Length < 2048 ? input.Length : 2048;
                byte[] buffer = new byte[bufferSize];       //缓冲区
                int bytesRead = 0;
                while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
                {
                    ds.Write(buffer, 0, bytesRead);
                }
                //output.Flush();  有无注释都试过了
            }
            catch(ApplicationException e)
            {
                MessageBox.Show(e.StackTrace);
            }

试试看
byte[] bytes = new byte[ds.Length];
ds.Read(bytes, 0, bytes.Length);
ds.Seek(0, SeekOrigin.Begin);
System.IO.File.WriteAllBytes("1.bin", bytes);

DeflateStream ds = new DeflateStream(output, CompressionMode.Compress);
ds.Write(input.ToArray, 0, input.ToArray.Length)

(output.ToArray)就是压缩数据