C#解压GZip文件源码

2018-12-13  本文已影响0人  简简单单咦

下面内容内容是关于C#解压GZip文件的内容,应该对小伙伴们有所用。

        public void ungzip(string path, string decomPath, bool overwrite)

        {

            if (File.Exists(decomPath))

            {

                if (overwrite)

                {

                    File.Delete(decomPath);

                }

                else

                {

                    throw new IOException("The decompressed path you specified already exists and cannot be overwritten.");

                }

            }

            GZipStream stream = new GZipStream(new FileStream(path, FileMode.Open, FileAccess.ReadWrite), CompressionMode.Decompress);

            FileStream decompressedFile = new FileStream(decomPath, FileMode.OpenOrCreate, FileAccess.Write);

            int data;

            {

                decompressedFile.WriteByte((byte)data);

            }

            decompressedFile.Close();

            stream.Close();

        }

上一篇 下一篇

猜你喜欢

热点阅读