我有来自使用 Sevenzipsharp 库创建的程序的 sfx 文件。仍然当我直接双击文件 sfx 执行时,如果使用了错误的密码,但仍然以 0 字节的大小提取其中的文件,如果有人应该添加另一种模式来运行“压缩”,以便在我执行文件时sfx 错误的密码文件根本不被提取。
压缩代码:
public void Compress()
{
SevenZipCompressor.SetLibraryPath("7z.dll");
SevenZipCompressor cmp = new SevenZipCompressor();
cmp.Compressing += new EventHandler<ProgressEventArgs>(cmp_Compressing);
cmp.FileCompressionStarted += new EventHandler<FileNameEventArgs>(cmp_StartCompress);
cmp.CompressionFinished += new EventHandler<EventArgs>(cmp_CompleteCompressed);
cmp.ArchiveFormat = OutArchiveFormat.SevenZip;
cmp.CompressionLevel = CompressionLevel.Normal;
cmp.CompressionMethod = CompressionMethod.Lzma;
cmp.CompressionMode = CompressionMode.Create;
string password = txtPasswordEn.Text;
string DirFile = tempFolder;
string NameFileCompress = Path.Combine(txtOutputFileEn.Text, txtNameFile.Text) + (".zip");
cmp.BeginCompressDirectory(DirFile, NameFileCompress, password, ".",true);
}
创建 SFX 代码:
public void CreateSfx()
{
string location = Path.Combine(txtOutputFileEn.Text, txtNameFile.Text);
string nameZip = location + (".zip");
string nameExe = location + (".exe");
SfxModule mdl = SfxModule.Extended;
SevenZipSfx sfx = new SevenZipSfx(mdl);
sfx.ModuleFileName = @"7z.sfx";
sfx.MakeSfx(nameZip, nameExe);
}