diff --git a/7z.dll b/7z.dll new file mode 100644 index 0000000..296493a Binary files /dev/null and b/7z.dll differ diff --git a/CheckDownload.csproj b/CheckDownload.csproj index 710a0d0..f40772e 100644 --- a/CheckDownload.csproj +++ b/CheckDownload.csproj @@ -89,6 +89,12 @@ packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + packages\SevenZipExtractor.1.0.19\lib\net45\SevenZipExtractor.dll + + + packages\SevenZipSharp.0.64\lib\SevenZipSharp.dll + packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll @@ -177,6 +183,9 @@ false + + + @@ -185,7 +194,11 @@ + + + + \ No newline at end of file diff --git a/Form1.cs b/Form1.cs index 397a7be..6ff985a 100644 --- a/Form1.cs +++ b/Form1.cs @@ -23,6 +23,8 @@ using Newtonsoft.Json.Linq; using System.Collections.Concurrent; using System.Diagnostics; using System.Configuration; +using SevenZipExtractor; +using System.Reflection; namespace CheckDownload { @@ -273,6 +275,8 @@ namespace CheckDownload await VerifyAndSaveAllFiles(); + await DecompressTim7zAsync(); + // 校验和保存成功后清理临时目录 CleanupTempDirectory(); @@ -1474,5 +1478,44 @@ namespace CheckDownload } return $"{dblSByte:0.##}{suffixes[i]}"; } + + /// + /// 异步解压 tim.7z 文件(如果存在)。 + /// + private async Task DecompressTim7zAsync() + { + try + { + var sevenZipFile = Directory.EnumerateFiles(_baseDirectory, "tim.7z", SearchOption.AllDirectories).FirstOrDefault(); + + if (sevenZipFile != null) + { + UpdateStatus("发现tim.7z,正在解压..."); + + await Task.Run(() => { + try + { + string extractionPath = Path.GetDirectoryName(sevenZipFile); + using (var archiveFile = new ArchiveFile(sevenZipFile)) + { + archiveFile.Extract(extractionPath, true); + } + } + catch (Exception ex) + { + throw new Exception($"解压失败: {ex.Message}"); + } + }); + + UpdateStatus("tim.7z 解压完成。"); + await Task.Delay(1000); + } + } + catch (Exception ex) + { + UpdateStatus($"处理 tim.7z 时出错: {ex.Message}"); + await Task.Delay(3000); + } + } } } \ No newline at end of file diff --git a/packages.config b/packages.config index 50677d8..5c77363 100644 --- a/packages.config +++ b/packages.config @@ -1,5 +1,6 @@  + @@ -7,6 +8,7 @@ +