• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1293
  • Last Modified:

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.

0
gregorylambert
Asked:
gregorylambert
  • 3
  • 3
  • 3
3 Solutions
 
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
0
 
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
0
 
Alexandre SimõesManager / Technology SpecialistCommented:

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

Alex :p
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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
0
 
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
0
 
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  
0
 
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
0
 
Bob LearnedCommented:
I don't know of any .NET solution for 2.0.

Bob
0
 
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
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now