首页 > 编程知识 正文

C#解压GZ文件

时间:2023-05-05 16:29:09 阅读:184226 作者:1841

public void ungzip(string path, string decomPath, bool overwrite) { //for overwriting purposes if (File.Exists(decomPath)) { if (overwrite) { File.Delete(decomPath); } else { throw new IOException("The decompressed path you specified already exists and cannot be overwritten."); } } //create our file streams GZipStream stream = new GZipStream(new FileStream(path, 体贴的项链, FileAccess.ReadWrite), CompressionMode.Decompress); FileStream decompressedFile = new FileStream(decomPath, 体贴的项链OrCreate, FileAccess.Write); //data represents a byte from the compressed file //it's set through each iteration of the while loop int data; while ((data = stream.ReadByte()) != -1) //iterates over the data of the compressed file and writes the decompressed data { decompressedFile.WriteByte((byte)data); } //close our file streams decompressedFile.Close(); stream.Close(); }

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。