zoukankan      html  css  js  c++  java
  • SevenZipShaper压缩类

    //7z下载或者自己去找个地址 nurget,github之类的 链接:https://pan.baidu.com/s/1__dPu7X5b8Xr_ej9ya7Kdg 密码:q8nw
    using
    SevenZip; using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { //SevenZipCompressorFile(@"D:TEMPCLR.7z", @"C:UsersadminDesktopCLR.pdf", 10 * 1024 * 1024); SevenZipDecompressFile(@"D:TEMPCLR.7z", @"d: empCLR"); //SevenZipCompressorFile(@"d:Temparch111.7z", @"d:Templog.txt", 1024 * 1024 * 10); //SevenZipDecompressFile(@"d:Temparch111.7z", @"d: empaa1"); Console.WriteLine("6666"); Console.Read(); } /// <summary> /// SevenZipCompressorFile(@"d:Temparch111.7z", @"d:Templog.txt",1024*1024*10); /// </summary> /// <param name="compressAfterFileName"></param> /// <param name="compressBeforeFileName"></param> /// <param name="volumeSize"></param> private static void SevenZipCompressorFile(string compressAfterFileName,string compressBeforeFileName,int volumeSize=0) { SevenZipCompressor tmp = new SevenZipCompressor(); if (volumeSize > 0) { tmp.VolumeSize = volumeSize; } tmp.CompressFiles(compressAfterFileName,compressBeforeFileName);//CompressFiles } /// <summary> /// 解压7z文件 Decompress7zFile(@"D:Tempaa.7z", @"d: empaa1"); /// </summary> /// <param name="sevenzipFileName">要解压的7z文件在哪里如D:Tempaa.7z</param> /// <param name="decompressFileToPath">解压到哪里如d: empaa1</param> public static void SevenZipDecompressFile(string sevenzipFileName,string decompressFileToPath) { if (File.Exists(sevenzipFileName)) { using (SevenZipExtractor tmp = new SevenZipExtractor(sevenzipFileName)) { tmp.ExtractFiles(decompressFileToPath, tmp.ArchiveFileData.Select(x => x.Index).ToArray()); } } else if (File.Exists(sevenzipFileName+".001")) { using (SevenZipExtractor tmp = new SevenZipExtractor(sevenzipFileName+".001")) { tmp.ExtractFiles(decompressFileToPath, tmp.ArchiveFileData.Select(x => x.Index).ToArray()); } } } /// <summary> /// 7z压缩目录 CompressDirectory(@"C:UsersadminDesktopExport", @"d:Tempaa.7z"); /// </summary> /// <param name="directoryPath">要压缩的目录如C:UsersadminDesktopExport</param> /// <param name="compressToPath">压缩到哪里如d:Tempaa.7z</param> /// <param name="VolumeSize">每个压缩文件的块大小如果文件较大,可能需要压缩为多个文件如 aa.7z.001,aa.7z.002</param> public static void SevenZipCompressDirectory(string directoryPath,string compressToPath,int VolumeSize=0) { SevenZipCompressor tmp = new SevenZipCompressor(); if (VolumeSize > 0) { tmp.VolumeSize = 10 * 1024 * 1024; } tmp.CompressDirectory(directoryPath, compressToPath); } } }
  • 相关阅读:
    包和常用内置模块(二)
    常用内置模块(一)
    正则表达式和re模块
    迭代器和生成器
    函数(四)
    函数(三)闭包函数与装饰器
    Codeforces Round #539 (Div. 2) D 思维
    Codeforces Round #539 (Div. 2) 异或 + dp
    Codeforces Round #546 (Div. 2) E 推公式 + 线段树
    牛客练习赛42 C 反着计算贡献
  • 原文地址:https://www.cnblogs.com/kexb/p/9512650.html
Copyright © 2011-2022 走看看