7-zip compression on asp.net website

I am trying to use 7-zip compression to create a sample zip file as stated in the example http://www.dotnetperls.com/7-zip As the url says, "you must specify" Copy if new "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 get the option to specify "Copy if new" when I see the properties of 7za.exe in the properties window

But when I use VS website, I cannot find this setting. As a result, when I debug this program, it says that it cannot be found 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 new" option in the case of the VS website?

Thank!

+3


source to share


2 answers


Personally, I would never dare to start a new process from an ASP.NET application.

The reason is because I don't know if the process might or might not show in some windows, or do something like a single instance.



If I had to solve your requirement, I would use a class library to work with 7zip files .

+1


source


You need to provide the path for 7za.exe. Keep in mind that the web page runs under an anonymous user account or application pool. These accounts must also have path and exe permissions for 7zip.



+2


source







All Articles