[英]Cannot read that as a ZipFile for .exe file C#
I'm using SevenZIP library files to unzip/extract .exe file. 我正在使用SevenZIP库文件来解压缩/.exe文件。 When i tried this approcah I'm getting a error
Cannot read that as a ZipFile
& zip exception was unhanded
. 当我尝试此方法时,出现错误
Cannot read that as a ZipFile
未处理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. 我不想在我的项目中使用任何7zip.exe控制台应用程序,我更喜欢在我的项目中使用.dll文件。
Is there any other way to extract .exe file? 还有其他方法可以提取.exe文件吗?
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而不是SevenZipLib 。 DotNetZip can only extract
.zip
files, not 7-zip nor .exe
. DotNetZip只能提取
.zip
文件,而不能提取7-zip或.exe
。
Instead of using SevenZip lib, try 7zip.exe in console. 而不是使用SevenZip lib,请在控制台中尝试7zip.exe。 Use Process class to execute 7zip.exe.
使用Process类执行7zip.exe。 It works perfect.
完美的作品。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.