C#中用SharpZipLib生成gzip/解壓文件-創(chuàng)新互聯(lián)

Code tells all:

創(chuàng)新互聯(lián)是一家專注于網站設計制作、成都做網站與策劃設計,咸豐網站建設哪家好?創(chuàng)新互聯(lián)做網站,專注于網站建設十余年,網設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:咸豐等地區(qū)。咸豐做網站價格咨詢:13518219792
using System;
using System.IO;
using ICSharpCode.SharpZipLib.GZip;
using ICSharpCode.SharpZipLib.Core;

namespace CNKIDataExport
{
    class Program
    {
        public static void gZipFile(string filePath, string zipFilePath)
        {
            Stream s = new GZipOutputStream(File.Create(zipFilePath));
            FileStream fs = File.OpenRead(filePath);
            int size;
            byte[] buf = new byte[4096];
            do
            {
                size = fs.Read(buf, 0, buf.Length);
                s.Write(buf, 0, size);
            } while (size > 0);
            s.Close();
            fs.Close();
        }

        public static void gunZipFile(string zipFilePath, string filePath)
        {
            using (Stream inStream = new GZipInputStream(File.OpenRead(zipFilePath)))
            using (FileStream outStream = File.Create(filePath))
            {
                byte[] buf = new byte[4096];
                StreamUtils.Copy(inStream, outStream, buf);
            }
        }

        static void Main(string[] args)
        {
            string src = @"D:\test\in.txt"
            string dest = @"D:\test\out.gz"
            string ori = @"D:\test\ori.txt"

            gZipFile(src, dest);
            Console.WriteLine("gzip over!");
            gunZipFile(dest, ori);
            Console.WriteLine("gunzip over!");
            Console.ReadKey();
        }
    }
}

相關鏈接:

1、SharpZipLib下載

2、Using SharpZipLib to gzip a file

3、ICSharpCode.SharpZipLib.GZip.GZipInputStream Class Reference

4、C#利用SharpZipLib解壓或壓縮文件夾實例操作(ZIP格式)

*** walker ***

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

網站名稱:C#中用SharpZipLib生成gzip/解壓文件-創(chuàng)新互聯(lián)
網頁URL:http://www.muchs.cn/article24/dhjdce.html

成都網站建設公司_創(chuàng)新互聯(lián),為您提供電子商務云服務器、外貿建站、定制網站、面包屑導航網站改版

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

外貿網站建設