I am trying to use 7-zip compression to create a zip of a sample file as given in the example
http://www.dotnetperls.com/7-zip
As the URL says, “you must specify “Copy if newer” or “Copy always” to copy files such as executables to the output directory.”
I found that when I use this code in a VS Project, I do get the option to specify “Copy if newer” when I see properties of 7za.exe in the properties window
But when I use in a VS Web site, I am unable to find this option. As a result, when I debug this program, it saying that its unable to find 7za.exe
string sourceName = "pdfSample.pdf";
string targetName = "pdfSample.gz";
ProcessStartInfo p = new ProcessStartInfo();
p.FileName = "7za.exe";
p.Arguments = "a -tgzip \"" + targetName + "\" \"" + sourceName + "\" -mx=9";
p.WindowStyle = ProcessWindowStyle.Hidden;
try
{
Process x = Process.Start(p);
x.WaitForExit();
}
catch (Exception ex)
{
Console.Write(ex.ToString());
}
Any idea why there is no “Copy if newer” option in case of VS Web site?
Thanks!
Personally, I would never dare to start a new process from within an ASP.NET application.
The reason is that I don’t know whether the process may or may not show up some windows or do other things like single-instance.
If I had to solve your requirement, I would use a class library to work with 7zip files.