首页新闻找找看学习计划

ICSharpCode.SharpZipLib.Zip.ZipInputStream 解压内存一直长

0
[已关闭问题] 关闭于 2014-12-02 09:54

代码如下:

        /// <summary>
        /// ZIP解压
        /// </summary>
        /// <param name="fileName">fileName</param>
        /// <returns>Decompress</returns>
        public static string Decompress(string fileName)
        {
            byte[] file = null;
            using (MemoryStream outBuffer = new MemoryStream())
            {
                using (FileStream stream = new FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read))
                {
                    using (ZipInputStream compressedzipStream = new ZipInputStream(stream))
                    {
                        byte[] block = new byte[10240];

                        ZipEntry entry = null;
                        while ((entry = compressedzipStream.GetNextEntry()) != null)
                        {
                            while (true)
                            {
                                int bytesRead = compressedzipStream.Read(block, 0, block.Length);
                                if (bytesRead <= 0)
                                {
                                    break;
                                }
                                else
                                {
                                    outBuffer.Write(block, 0, bytesRead);
                                }
                            }
                        }

                        compressedzipStream.Dispose();
                        compressedzipStream.Close();
                    }

                    stream.Dispose();
                    stream.Close();
                }

                file = outBuffer.ToArray();
                outBuffer.Dispose();
                outBuffer.Close();
            }

            return Encoding.UTF8.GetString(file);
        }

 

这段代码跑一次,内存就长一倍,改释放的资源都释放了呀??

西普士的主页 西普士 | 菜鸟二级 | 园豆:202
提问于:2014-12-02 09:38
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册