I'm using SevenZIP library files to unzip/extract .exe file. When i tried this approcah I'm getting a error Cannot read that as a ZipFile
& zip exception was unhanded
. I don't want to use any 7zip.exe console app in my project & i prefer to use .dll files in my project.
Is there any other way to extract .exe file?
private void MyExtract()
{
if(x86)
ExtractZip(@"D:\22.1.2.702\64\953-win_x86.exe", ".");
else
ExtractZip(@"D:\22.1.2.702\64\.702-win_x64.exe", ".");
}
private void ExtractZip(string zipFile, string directory)
{
using (var zip1 = ZipFile.Read(zipFile))
{
// here, we extract every entry, but we could extract conditionally
// based on entry name, size, date, checkbox status, etc.
foreach (var e in zip1)
{
e.Extract(directory, ExtractExistingFileAction.OverwriteSilently);
}
}
}
Code sample looks like you are using DotNetZip and not SevenZipLib . DotNetZip can only extract .zip
files, not 7-zip nor .exe
.
Instead of using SevenZip lib, try 7zip.exe in console. Use Process class to execute 7zip.exe. It works perfect.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.