How to create a SFX ZIP with SevenZipSharp?

送分小仙女□ 提交于 2019-12-24 01:53:40

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5637668/how-to-create-a-sfx-zip-with-sevenzipsharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!