using Shell32 on multiple platforms

I have an app that unzips a file using shell32, developed and works on W7, on XP get the following error:
Unable to cast COM object of type 'Shell32.ShellClass' to interface type 'Shell32.IShellDispatch5' ...

Found the following fix: http://nerdynotes.blogspot.com/2008/06/vbnet-shell32-code-compiled-on-vista.html

But this just throws the following error: "Object reference not set to an instance of an object."

Old Code that worked on W7 not XP:
          Dim sc As New Shell32.Shell()
          Dim output As Shell32.Folder = sc.NameSpace(sTempFilesFldr)
          Dim input As Shell32.Folder = sc.NameSpace(sPath)
          x = input.Items.Count
          ...

Open in new window

Code from site, not working:
        Dim ShellAppType As Type = Type.GetTypeFromProgID("Shell.Application")
        Dim sc As Object = Activator.CreateInstance(ShellAppType)
        Dim output As Shell32.Folder = sc.NameSpace(sTempFilesFldr)
        Dim input As Shell32.Folder = sc.NameSpace(sPath)
        x = input.Items.Count
        ...

Open in new window


Thanks
sidwelleAsked:
Who is Participating?
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.

sidwelleAuthor Commented:
Solved some of it, adding '.ToString' to the path values caused it to work on the W7 system.

1        Dim output As Shell32.Folder = sc.NameSpace(sTempFilesFldr.ToString)
2        Dim input As Shell32.Folder = sc.NameSpace(sPath.ToString)
3        x = input.Items.Count

Open in new window


But the 3rd line still fails on XP systems ??
Still have the same problem, can't use this code on XP system.
0
Bob LearnedCommented:
There are platform-independent zip libraries, such as SharpZibLib:

The Zip, GZip, BZip2 and Tar Implementation For .NET
http://www.icsharpcode.net/opensource/sharpziplib/

Is there a reason to use a Windows-specific shell method?
0

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
sidwelleAuthor Commented:
Thanks for the link, let me look at it for a few days.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

sidwelleAuthor Commented:
Looking at the examples its a little cryptic.

opened example: ...vb\zipfiletest

but to make this work I referenced the lib in ...\SharpZipLib_0860_Bin\netcf-20\ICSharpCode.SharpZipLib.dll

but the other examples that do have a de/compression example(s) won't work with this library, you have to load the example from: \SharpZipLib_0860_Bin\net-20\ICSharpCode.SharpZipLib.dll  and then the first example won't work.


In the function: btnTest_Click

                dim data() as byte
                data = objEntry.ExtraData
                File.WriteAllBytes(sOutFolder & fileName, data)


But what I get is the raw data, not decompressed.
0
Bob LearnedCommented:
Is this for the Compact Framework (CF), or full framework?  What .NET version is your application?
0
sidwelleAuthor Commented:
This is full framework 3.5

The dotnetzip library works very well and it seems like it is easy to use.
0
Bob LearnedCommented:
I have downloaded that library, and rebuilt is for .NET framework 4.0, since it is 2.0 out of the box.
0
sidwelleAuthor Commented:
I am using the DotNetZip in my project, seems to work and simple,  I don't have time to put a whole lot of effort on this project.

Thanks
0
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.