分3种操作方式
1、获取路径,逐个文件解压
DateTime beforDT1 = System.DateTime.Now;
SevenZipExtractor sevenZipExtractor1 = new SevenZipExtractor("Downloads.7z");
foreach (string it in sevenZipExtractor1.ArchiveFileNames)
{
Console.WriteLine(it);
sevenZipExtractor1.ExtractFiles("123", it);
}
sevenZipExtractor1.Dispose();
DateTime afterDT1 = System.DateTime.Now;
TimeSpan ts1 = afterDT1.Subtract(beforDT1);
Console.WriteLine("DateTime总共花费{0}ms.", ts1.TotalMilliseconds);
2、获取路径,一次性全解压
DateTime beforDT = System.DateTime.Now;
SevenZipExtractor sevenZipExtractor = new SevenZipExtractor("Downloads.7z");
List<string> files = new List<string>();
foreach (string it in sevenZipExtractor.ArchiveFileNames)
{
Console.WriteLine(it);
files.Add(it);
}
sevenZipExtractor.ExtractFiles("Downloads1", files.ToArray());
sevenZipExtractor.Dispose();
DateTime afterDT = System.DateTime.Now;
TimeSpan ts = afterDT.Subtract(beforDT);
Console.WriteLine("DateTime总共花费{0}ms.", ts.TotalMilliseconds);
3、直接解压目录
DateTime beforDT2 = System.DateTime.Now;
SevenZipExtractor sevenZipExtractor2 = new SevenZipExtractor("Downloads.7z");
sevenZipExtractor2.ExtractArchive("Downloads2");
DateTime afterDT2 = System.DateTime.Now;
TimeSpan ts2 = afterDT2.Subtract(beforDT2);
sevenZipExtractor2.Dispose();
Console.WriteLine("DateTime总共花费{0}ms.", ts2.TotalMilliseconds);
第2和3种方式耗费时间相似,比较短,第一类耗时相当长。
Console.WriteLine("DateTime总共花费...........");
Console.WriteLine("DateTime总共花费t1 {0}ms.", ts1.TotalMilliseconds);
Console.WriteLine("DateTime总共花费t0 {0}ms.", ts.TotalMilliseconds);
Console.WriteLine("DateTime总共花费t2 {0}ms.", ts2.TotalMilliseconds);
输出结果中:
t1 49986.8883ms
t0 5974.8105ms
t2 6208.8108ms