Question

I have an installer for VB6 application and I need to decompress the files individually with c#. All files end with an underscore, eg image.jp_. I saw with 7ZIP program that files are compressed with MSZIP compression mode, but I can not decompress.

EDIT

My solution

How to create a CAB (cabinet) file using C#

based on the use of WiX, I use as explained in the link the DLL:

Microsoft.Deployment.Compression.dll
Microsoft.Deployment.Compression.Cab.dll

and then instead of using the CAB file, I put my file image.jp_ and it worked perfectly. Thank you all for trash me the question, and Charly, I love to say thanks

CabInfo cab = new CabInfo(@"C:\test\image.jp_");
cab.Unpack(@"C:\test\");

thanks

Was it helpful?

Solution 3

(at the request of @Stijn)

My solution

How to create a CAB (cabinet) file using C#

based on the use of WiX, I use as explained in the link the DLL:

Microsoft.Deployment.Compression.dll Microsoft.Deployment.Compression.Cab.dll

and then instead of using the CAB file, I put my file image.jp_ and it worked perfectly. Thank you all for trash me the question.

CabInfo cab = new CabInfo(@"C:\test\image.jp_");
cab.Unpack(@"C:\test\");

in my case I find very simple to do, I already had installed the WiX for another project but you can download and install very simply.

Then you just have to go to the installation folder or find these DLL and copy for use in our application.

all other solutions "ZIP" or "GZip" or libraries based on this, does not work. if anyone has another solution for. NET 4.0 will be very welcome

thanks

OTHER TIPS

There's lots of piquant history behind this question. A long, long time ago in a galaxy far away, Microsoft got caught with their hands in the cookie jar. Back when they were still a small company making a living out of selling DOS licenses. A company called Stac Electronics figured out a way to make DOS work better. Lots of opportunity, disk drives were still very slow and processors were getting faster.

Stac came up with a DOS utility that compressed files automatically, without DOS being aware that this happened. Compressing them before they got written to the disk and decompressing them when they got read. DOS only ever saw the uncompressed version of the file. Very popular at the time, it made disk access an easy x2 faster.

So Microsoft went "good idea! We can do that too". And made their own version of it called DoubleSpace and released it to the world in DOS version 6.0. Stac wasn't thrilled, instant death to their reason for being and sued Microsoft. And won. $120 million dollars. That hurt. A lot. It was the equivalent of adding a surcharge of $5.50 to every copy of DOS having been sold already and Microsoft back then was already really heavy into making sure every PC came with DOS preinstalled by making the price attractive.

Microsoft had a very hard time recovering from that, compression was a dirty word in the company for a very, very long time. Very visible in the .NET framework for example, support for .zip archives has always been missing until just recently.

Long story short, they came up with their own compression scheme, one that didn't violate anybody's patents. Not much left, it sucked heavily. Which is what you ran into, MSZIP is not the appropriate label for it. You'll have to run a program called expand.exe to decompress the file, available on every Windows version. Type "expand /?" for help. Ask more questions about it at superuser.com

One possibility would be to import the cabinet.dll or SetupApi.DLL library and use extern calls to invoke methods on it. This article discusses the approach.

You'll need prototypes like these:

[DllImport("setupapi.dll")]
internal static extern IntPtr SetupDiGetClassDevsEx(IntPtr ClassGuid, 
[MarshalAs(UnmanagedType.LPStr)]String enumerator, 
IntPtr hwndParent, Int32 Flags, IntPtr DeviceInfoSet, 
[MarshalAs(UnmanagedType.LPStr)]String MachineName, IntPtr Reserved);

[DllImport("setupapi.dll")]
internal static extern Int32 SetupDiDestroyDeviceInfoList(IntPtr DeviceInfoSet);

The article doesn't talk about MSZIP deflation specifically, though.

Another possibility might be to use the 7Z SDK, as mentioned in this SO question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top