How can I programmatically extract cabinet (CAB) files in Visual Basic .NET (not VB6)

I am using VB.NET (VS 2005) and I am looking for either sample code or controls (commercial or free) that will provide programmatic access to extracting files from specified Cabinet (CAB) files.

I understand that there are samples for VB6 - however these samples do not upgrade to VB.NET (as far as I have tried) and I am looking for a strong .NET solution.

gregorylambertAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Alexandre SimõesManager / Technology SpecialistCommented:

If you open a commandprompt window write Makecab and press Return, you'll see that there's a DOS command that does just what you need.
You just have to call it and pass the arguments you want:

     System.Diagnostics.Process.Start("MAKECAB.EXE", "c:\\myFile.txt");

Take a look at the MAKEBAB...

Alex :p
Bob LearnedCommented:
Actually to extract files from a Cabinet file, you need the EXTRACT command:

EXPAND -D cab1.cab -F:file.txt

Also, this is a VB.NET question.

Bob
Alexandre SimõesManager / Technology SpecialistCommented:

Ups... sorry mate... at 02:08AM I may start confusing! :)

Alex :p
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

gregorylambertAuthor Commented:
Hi,

Thanks for taking the time to answer my question. This solution "works" but it is the one that I am trying to avoid. I am trying to get a fully .NET solution developed and I am trying to avoid "shelling out" to external executables.

Hopefully, I made that clear in the question "header/title" - don't want to waste anybodys time.

I am going to raise the points for this solution -I am pretty keen to get a .NET CAB control or sample code.

cheers,

g
gregorylambertAuthor Commented:
Hi,

With reference to the shell out to EXTRACT command, here is the sample code that I "don't" want to use (my preference is a .NET control):

Here is the sample code for shelling out to the MS windows 2000 reskit CAB expanding EXTRACT tool

        Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
        myProcess.StartInfo.FileName = "C:\Program Files\Resource Kit\extract.exe /c c:\temp\extract\orca.cab *.*"
        myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
        myProcess.Start()

This sample allows the VB app to still have some control over the process (i.e. it waits for the extraction to finish before moving on to the next thing) and even hides the window so user thinks that everything is "cool" - no dodgy black pop-up windows.

cheers,

g
Bob LearnedCommented:
You need to specify the filename separate from the arguments:

  myProcess.StartInfo.FileName = "C:\Program Files\Resource Kit\extract.exe"
  myProcess.StartInfo.Arguments = " /c c:\temp\extract\orca.cab *.*"
  myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden

Bob  

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gregorylambertAuthor Commented:
Bob,

Thanks for the comments on the command line arguments. I eventually figured that one out this morning.

However, this is the solution I don't want.

:)

Any ideas on a .NET solution? I have now raised the pot to 500 points - Whooho!

I would greatly appreciate any help on pursuing the .NET solution.

cheers,

g
Bob LearnedCommented:
I don't know of any .NET solution for 2.0.

Bob
Alexandre SimõesManager / Technology SpecialistCommented:
Hi...
Why don'y you want this solution?

The only possible reason I can think is because the computer eventually may not have that EXPAND.EXE file...
To prevent a possible error you can copy the exe to the app exe folder and access it as:

        Dim myProcess As System.Diagnostics.Process = New System.Diagnostics.Process()
        myProcess.StartInfo.FileName = System.Windows.Forms.Application.StartupPath + "\\extract.exe /c c:\temp\extract\orca.cab *.*"
        myProcess.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden
        myProcess.Start()


As my opinion for that .net solution you want...
I don't know any, and if it exists it's for sure just a wrapper around that Expand.exe file.

Alex :p
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.