Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decompress MSZIP files with c#?

Tags:

c#

c#-4.0

cab

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

like image 712
andres descalzo Avatar asked Dec 08 '22 12:12

andres descalzo


1 Answers

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

like image 86
Hans Passant Avatar answered Dec 27 '22 21:12

Hans Passant