1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using SevenZip;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Install.Core.Common
{
public static class SeverZipExt
{
public static void Uncompress(string path_7z, string dstPath)
{
string path = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;// Assembly.GetExecutingAssembly().Location;
path = Path.GetDirectoryName(path);
//exe的根目录
//设置7z.dll 路径
path = Path.Combine(path, Environment.Is64BitProcess ? "x64" : "x86", "7z.dll");
SevenZip.SevenZipBase.SetLibraryPath(path);
//先删除
if (Directory.Exists(dstPath))
{
Directory.Delete(dstPath, true);
}
using (var tmp = new SevenZipExtractor(path_7z))
{
tmp.ExtractArchive(dstPath);
//for (var i = 0; i < tmp.ArchiveFileData.Count; i++)
//{
// tmp.ExtractFiles($@"{dstPath}\", tmp.ArchiveFileData[i].Index);
//}
}
//删除xxx.7z
//File.Delete(filePath);
// return true;
}
}
}