欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
文件壓縮類(lèi)
//下面的壓縮文文件代碼我是在網(wǎng)上擇錄下來(lái)

調用此類(lèi)之前需要在http://www.icsharpcode.net/OpenSource/SharpZipLib/下載SharpZipLib 然后將ICSharpCode.SharpZipLib.dll 引用一下

using System;
using System.Collections.Generic;
using System.Text;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Zip;
using ICSharpCode.SharpZipLib.GZip;
using System.IO;

namespace WindowsFormsApplication1
{
    public class ZipClass
    {
        public string cutStr = "";

        //Get all DirectoryInfo
        private void direct(DirectoryInfo di, ref ZipOutputStream s, Crc32 crc)
        {
            //DirectoryInfo di = new DirectoryInfo(filenames);
            DirectoryInfo[] dirs = di.GetDirectories("*");
            //遍歷目錄下面的所有的子目錄
            foreach (DirectoryInfo dirNext in dirs)
            {
                //將該目錄下的所有文件添加到 ZipOutputStream s 壓縮流里面
                FileInfo[] a = dirNext.GetFiles();
                this.writeStream(ref s, a, crc);

                //遞歸調用直到把所有的目錄遍歷完成
                direct(dirNext, ref s, crc);
            }
        }

        private void writeStream(ref ZipOutputStream s, FileInfo[] a, Crc32 crc)
        {
            foreach (FileInfo fi in a)
            {
                //string fifn = fi.FullName;
                FileStream fs = fi.OpenRead();

                byte[] buffer = new byte[fs.Length];
                fs.Read(buffer, 0, buffer.Length);


                //ZipEntry entry = new ZipEntry(file);   Path.GetFileName(file)
                string file = fi.FullName;
                file = file.Replace(cutStr, "");

                ZipEntry entry = new ZipEntry(file);

                entry.DateTime = DateTime.Now;

                // set Size and the crc, because the information
                // about the size and crc should be stored in the header
                // if it is not set it is automatically written in the footer.
                // (in this case size == crc == -1 in the header)
                // Some ZIP programs have problems with zip files that don't store
                // the size and crc in the header.
                entry.Size = fs.Length;
                fs.Close();

                crc.Reset();
                crc.Update(buffer);

                entry.Crc = crc.Value;

                s.PutNextEntry(entry);

                s.Write(buffer, 0, buffer.Length);
            }
        }

        /// <summary>
        /// 主調函數
        /// </summary>
        /// <param name="args">args[0]為你要壓縮的目錄所在的路徑
        /// 例如:D:\\temp\\  (注意temp 后面加 \\ 但是你寫(xiě)程序的時(shí)候怎么修改都可以)
        /// args[1]為壓縮后的文件名及其路徑
        /// 例如:D:\\temp.zip
        /// </param>
        public void ZipFileMain(string[] args)
        {
            //string filenames = Directory.GetFiles(args[0]);

            Crc32 crc = new Crc32();
            ZipOutputStream s = new ZipOutputStream(File.Create(args[1]));

            s.SetLevel(6); // 0 - store only to 9 - means best compression

            DirectoryInfo di = new DirectoryInfo(args[0]);

            FileInfo[] a = di.GetFiles();

            cutStr = args[0].Trim();
            //壓縮這個(gè)目錄下的所有文件
            writeStream(ref s, a, crc);
            //壓縮這個(gè)目錄下子目錄及其文件
            direct(di, ref s, crc);

            s.Finish();
            s.Close();
        }
    }

}

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
何應用java.util.zip包現數據壓縮與解壓
C#生成ZIP壓縮包
代碼解壓和壓縮文件
利用JAVA API函數實(shí)現數據的壓縮與解壓縮(3)
C#使用ICSharpCode.SharpZipLib.dll壓縮文件夾和文件
如何將文件打成zip包并下載
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久