我想要通过我的控制台应用程序压缩文件夹,这就是为什么我使用类似这样的东西
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,不管它是怎么打开的。
发布于 2012-02-25 23:47:45
您可以避免使用ProcessStartInfo.WindowStyle属性打开窗口
试试这个:
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "C:\\Program Files\\WinZip\\winzip32.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;发布于 2012-02-25 21:43:44
也许您正在传递带有空格的路径(在zipName和folderName参数中),而没有用双引号将它们括起来。
发布于 2012-02-25 21:42:36
,http://www.rondebruin.nl/parameters.htm,->,我会认为代码是:
startInfo.Arguments = string.Format("-e {0} {1}",zipName,folderName);
https://stackoverflow.com/questions/9444471
复制相似问题