首页 新闻 会员 周边 捐助

GZipStream 关于解压问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2015-01-13 13:31

我的原始文件是 .zip  zip中有个文件夹,文件夹下是需要的文件.txt

 

通过gzip下载到本地,然后通过GZipStream 解压文件

 

高手来帮忙解决一下

问题补充:

我在网上找到这个

 

 public static string DeCompress(string fileName, string dirPath)
        {
            string iid = string.Empty;
            using (Stream source = File.OpenRead(fileName))
            {
                using (Stream destination = new MemoryStream())
                {
                    using (GZipStream input = new GZipStream(source, CompressionMode.Decompress, true))
                    {

                        byte[] bytes = new byte[4096 * 100];
                        int n = input.Read(bytes, 0, bytes.Length);

                        if (n > 0)
                        {
                            destination.Write(bytes, 0, n);
                        }
                    }
                    destination.Flush();
                    destination.Position = 0;

                    
                    DeSerializeFiles(destination, dirPath);
                }
            }

            return iid;
        }



        private static void DeSerializeFiles(Stream s, string dirPath)
        {
            BinaryFormatter b = new BinaryFormatter();
           
            ArrayList list = (ArrayList)b.Deserialize(s);

            foreach (SerializeFileInfo f in list)
            {
                string newName = dirPath + Path.GetFileName(f.FileName);
                using (FileStream fs = new FileStream(newName, FileMode.Create, FileAccess.Write))
                {
                    fs.Write(f.FileBuffer, 0, f.FileBuffer.Length);
                    fs.Close();
                }
            }
        }

 

标红出有异常,不知道怎么解决了

学点东西:)的主页 学点东西:) | 初学一级 | 园豆:6
提问于:2014-09-19 17:38
< >
分享
所有回答(1)
0

http://icsharpcode.github.io/SharpZipLib/

Yu | 园豆:12990 (专家六级) | 2014-09-20 09:02

哦,这几天忙别的了,嗯,我不想用第三方的dll

支持(0) 反对(0) 学点东西:) | 园豆:6 (初学一级) | 2014-09-26 09:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册