Question

I want zip folder through my console application that's why I used something like

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.
            }

        }

But this will give me error like winzip parameters validation error. Where I do mistake?

Update

I spell wrong on -eZ actually it may -ex etc... But another problem is that winzip open up own windows. I write for it -min however it opened.

Was it helpful?

Solution

You can avoid to open up windows by using ProcessStartInfo.WindowStyle property

Try this:

ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "C:\\Program Files\\WinZip\\winzip32.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;

OTHER TIPS

Perhaps you are passing paths with whitespaces (in zipName and folderName arguments) without enclosing them in double quotes.

http://www.rondebruin.nl/parameters.htm -> looking at that I would think the code is:

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

What is the option -eZ? I think that is your issue

I thought that that following are the only options to determine the compression method.

-ex = eXtra

-en = Normal

-ef = Fast

-es = Super fast

-e0 = no compression

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top