Question

I have been doing some research over the past couple days for a requirement to attach an InfoPath file (.xsn), convert it to a .cab and extract all the files from it. I cannot seem to find any good code snippets that allow this to happen. The majority of threads that i've come across thus far requires the use of a third party software which I want to avoid at all costs. I am thinking that I need to use a batch file to do the extraction. I have not been able to find any good posts or threads on this (that work).

Any helpful input or posts of how to accomplish this via Visual Basic or a batch file is much appreciated.

Was it helpful?

Solution

You will have to Add a reference to Microsoft Shell Controls and Automation. Once that is done, see this code snipet:

        Dim sc As New Shell32.Shell()
    IO.Directory.CreateDirectory("C:\test")
    Dim output As Shell32.Folder = sc.NameSpace("C:\test")
    Dim input As Shell32.Folder = sc.NameSpace("C:\Form1.cab")
    output.CopyHere(input.Items, 4)

This should do the trick.

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