How to execute winzip
command from MVC controller Action?
Command:
C:\Program Files (x86)\WinZip>WZZIP.EXE -ys2048000 Location Location
What you are asking, directly is possible with the System.Diagnostics.Process.Start(string, string)
method. It would look something like this:
System.Diagnostics.Process.Start(
@"C:\Program Files (x86)\WinZip\WZZIP.EXE",
"-ys2048000 Location Location");
I've gone down this path and for simple things it is probably good enough. I've often found that there are usually more cool, useful things you can do interacting directly with the zip files. In that case, something like DotNetZip or SharpZip are probably good alternatives. I've used DotNetZip before, its very robust and highly performant.
Here's a quick example from DotNetZip home page:
Here's some C# code that creates a zip file.
using (ZipFile zip = new ZipFile()) { // add this map file into the "images" directory in the zip archive zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images"); // add the report into a different directory in the archive zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files"); zip.AddFile("ReadMe.txt"); zip.Save("MyZipFile.zip"); }