How to create a SFX ZIP with SevenZipSharp?

2019-07-19 02:11发布

I have been looking at SevenZipSharp to create a self extracting zip file. The project page says that they have a special class SevenZipSfx that does this. However I have searched the object explorer and the documentation for version 0.64 and I cant find any reference to it.

Does anyone know if the class is missing or if there is a different meaning to "Special Class" that I'm missing?

2条回答
【Aperson】
2楼-- · 2019-07-19 02:44

It looks like the Sfx class isn't built by default. Grab the source code from Codeplex (or check out the trunk code) and add conditional compile constant SFX to the project settings and rebuild. Annoyingly the signing isn't in their source control so you'll have to disable code signing for the assembly.

Alternatively if this is a one-off SFX then you can build it yourself using the files in the SevenZip\sfx directory. If you look at the SevenZipSfx soruce you'll see it simply prepends one of those files taken from the assembly resources to the .7z archive.

查看更多
欢心
3楼-- · 2019-07-19 03:05

This code works for me, packs a directory with files within:

string destination = @"c:\my test.7z";
string pathToZip = @"C:\Program Files\7-Zip\7z.exe";
string directoryPath = @"c:\my test";

ProcessStartInfo p = new ProcessStartInfo();
p.FileName = pathToZip;
p.Arguments = string.Format("a -mx=9 \"{0}\" \"{1}\" -sfx", destination, directoryPath);

Process x = Process.Start(p);

99.9% work

查看更多
登录 后发表回答