我有sfx文件的程序,我创建了使用7.zipSharp库。如果我使用错误的密码直接执行文件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);
}发布于 2014-03-02 10:51:28
我刚刚看到,您创建的不是.zip文件,而是.7z文件(然后将其转换为自解压缩存档)。
对于该文件格式,可以使用EncryptHeaders属性实现文件名加密:
cmp.EncryptHeaders = true;https://stackoverflow.com/questions/22125973
复制相似问题