From 9f6e32d9bef5678f873ea7e441211fa1a8379978 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 1 Jun 2023 17:49:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PublishSite/PublishForm.cs | 50 ++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/PublishSite/PublishForm.cs b/PublishSite/PublishForm.cs index e18b0318..4193c831 100644 --- a/PublishSite/PublishForm.cs +++ b/PublishSite/PublishForm.cs @@ -25,6 +25,8 @@ using SharpCompress.Common; using System.IO.Compression; using MaterialSkin2DotNet.Controls; using MaterialSkin2DotNet; +using Renci.SshNet.Compression; +using SharpCompress.Archives; namespace PublishSite { @@ -1025,13 +1027,51 @@ namespace PublishSite try { - await Task.Run( () => - { + //await Task.Run( () => + //{ //将文件夹里的内容打包成压缩包 - ZipFile.CreateFromDirectory(localSourceFolder, filePath,CompressionLevel.Fastest,true); - - }); + //ZipFile.CreateFromDirectory(localSourceFolder, filePath,CompressionLevel.Fastest,true); + //Compress - Archive - Path "C:\Users\username\Documents\myfolder" - DestinationPath "C:\Users\username\Documents\myfolder.zip" - Force + + //var processStartInfo = new ProcessStartInfo + //{ + // FileName = "cmd.exe", + // RedirectStandardInput = true, + // UseShellExecute = false, + // CreateNoWindow = true + //}; + + //using (var process = new Process { StartInfo = processStartInfo }) + //{ + // process.Start(); + + // using (var writer = process.StandardInput) + // { + // if (writer.BaseStream.CanWrite) + // { + // // 执行命令:Compress-Archive -Path -DestinationPath -Force + + // var cmdCompress = $"Compress-Archive -Path \"{localSourceFolder}\" -DestinationPath \"{filePath}\" -Force"; + // writer.WriteLine(cmdCompress); + + // WinformLog(cmdCompress); + // writer.Close(); + // } + // } + + // process.WaitForExit(); + + // if (process.ExitCode != 0) + // { + // // 处理错误 + // } + //} + + + //}); + + WinformLog($"打包结束"); } catch (Exception ex) {