C#實(shí)現(xiàn)解壓GZip文件的方法
本文實(shí)例講述了C#實(shí)現(xiàn)解壓GZip文件的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
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, FileMode.Open, FileAccess.ReadWrite), CompressionMode.Decompress); FileStream decompressedFile = new FileStream(decomPath, FileMode.OpenOrCreate, 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(); }
希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。
相關(guān)文章
C#實(shí)現(xiàn)PDF頁(yè)面合并的示例代碼
這篇文章主要為大家介紹了如何利用C#及vb.net來(lái)實(shí)現(xiàn)合并PDF頁(yè)面內(nèi)容,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)C#有一定幫助,感興趣的小伙伴可以了解一下2022-04-04C#如何動(dòng)態(tài)創(chuàng)建lambda表達(dá)式
這篇文章主要介紹了C#如何動(dòng)態(tài)創(chuàng)建lambda表達(dá)式問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-02-02C#中Request.Cookies 和 Response.Cookies 的區(qū)別分析
本文通過(guò)實(shí)例代碼向我們展示了C#中Request.Cookies 和 Response.Cookies 的區(qū)別,文章淺顯易懂,這里推薦給大家。2014-11-11使用linq to xml修改app.config示例(linq讀取xml)
這篇文章主要介紹了使用linq to xml修改app.config示例,需要的朋友可以參考下2014-02-02C#開(kāi)發(fā)Android百度地圖手機(jī)應(yīng)用程序(多地圖展示)
這篇文章主要介紹了C#開(kāi)發(fā)Android百度地圖手機(jī)應(yīng)用程序(多地圖展示)的相關(guān)資料,需要的朋友可以參考下2016-02-02C#使用doggleReport生成pdf報(bào)表的方法
這篇文章主要介紹了C#使用doggleReport生成pdf報(bào)表的方法,結(jié)合實(shí)例形式分析了C# doggleReport安裝及使用具體操作技巧,需要的朋友可以參考下2017-06-06C#啟動(dòng)windows服務(wù)方法的相關(guān)問(wèn)題分析
C#啟動(dòng)windows服務(wù)的方法都是什么呢?C#啟動(dòng)服務(wù)類型為Disabled的windows服務(wù)會(huì)遇到什么樣的問(wèn)題呢?那么本文就向你介紹C#啟動(dòng)windows服務(wù)的方法的相關(guān)內(nèi)容2012-12-12