#67 7zipExample Automation Application In C#
While creating a download page for a website I came across the problem where the browser would open a .PDF
file instead of downloading it to the desktop of my PC when using the JavaScript window.location.href = "url/path/file.pdf";
function. A quick easy solution is to archive the .PDF
document as a .ZIP
file or .7z
etc. Now when the function is called the file will be downloaded.
Using a quick C# WinForms application I was able to automate the process. Here I have included a small demo project which may be useful on windows machines.
The Main function is as below:
A new process is started and Arguments are sent to the 7za.exe
console application.
7za.exe can also be used in the CMD console as well as with scripting languages such as PowerShell or Batch.