【发布时间】:2012-02-25 13:39:04
【问题描述】:
我想通过我的控制台应用程序压缩文件夹,这就是我使用类似的东西的原因
public void DoWinzip(string zipName, string password, string folderName)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "C:\\Program Files\\WinZip\\winzip32.exe";
startInfo.Arguments = string.Format("-min -eZ {0} {1}", zipName, folderName);
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch(Exception ex)
{
// Log error.
}
}
但这会给我类似 winzip 参数验证错误之类的错误。我哪里做错了?
Update
我在 -eZ 上拼写错误,实际上它可能是 -ex 等等……但另一个问题是 winzip 会打开自己的窗口。我为它写了-min 但是它打开了。
【问题讨论】:
-
为什么不使用 SharpZipLib (icsharpcode.net/opensource/sharpziplib)?然后您就可以完全控制压缩过程。
-
我这样做很好,但它提供的 zip 文件的 MB 大小比 winzip 大