2

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?

QueueHammer
  • 10,515
  • 12
  • 67
  • 91
  • Generally SFXs are a binary that you prepend to your .zip `copy /b SfxStub.exe + MyZip.zip MySfx.exe` - maybe it's a separate project / .exe? – Rup Apr 12 '11 at 15:39
  • Well, as crazy as finding a random exe from the internet and appending it to a zip then trying to run it sounded, i tried it. Did not work. So though the concept may be Unpacker.exe + Data.zip. It is slightly more complicated that that. – QueueHammer Apr 12 '11 at 17:50

2 Answers2

3

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.

Rup
  • 33,765
  • 9
  • 83
  • 112
  • Thank you, Rup. I created a work item here: http://sevenzipsharp.codeplex.com/workitem/10956 – Rami A. Jul 03 '12 at 00:44
  • @Rup can you explain step by step how to "**add conditional compile constant SFX to the project**" please? – ElektroStudios Apr 17 '13 at 17:10
  • @ElektroHacker In the Solution Explorer pane, right-click on the SevenZip (or SevenZip2010 project) and select Properties. On the Build tab there'll be a field "Conditional Compilation Symbols". Pick the build configuration you're interested in from the drop-down at the top, Debug or Release, and then append `, SFX` to the "Conditional Compilation Symbols" field. That should be enough if you now rebuild. If you get an error about missing .snk file when you build then you'll have to go to the signing tab in the project properties and untick the "sign the assembly" box. – Rup Apr 17 '13 at 17:53
0

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