0

我想通过我的控制台应用程序压缩文件夹,这就是为什么我使用类似的东西

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 但是它打开了。

4

4 回答 4

1

也许您正在传递带有空格(inzipNamefolderNamearguments)的路径,而没有将它们括在双引号中。

于 2012-02-25T13:43:43.527 回答
0

http://www.rondebruin.nl/parameters.htm -> 看着我认为代码是:

startInfo.Arguments = string.Format("-e {0} {1}", zipName, folderName);

于 2012-02-25T13:42:35.740 回答
0

有什么选择-eZ?我认为这是你的问题

我认为以下是确定压缩方法的唯一选项。

-ex= 额外的

-en= 正常

-ef= 快

-es= 超级快

-e0= 无压缩

于 2012-02-25T13:48:02.420 回答
0

您可以避免使用 ProcessStartInfo.WindowStyle 属性打开窗口

试试这个:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "C:\\Program Files\\WinZip\\winzip32.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
于 2012-02-25T15:47:45.497 回答