Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting rid of Interop.Shell32.dll
Message
From
20/07/2010 20:30:13
 
 
To
20/07/2010 20:14:31
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01473252
Message ID:
01473255
Views:
28
>It seems with the latest version of .NET that there are some issues with Interop.Shell32.dll. Basically, this one has never been part of the framework. It does not appear in the .NET references but in the COM references. I was using a reference to it to be able to use the Shell approach to zip a file or a directory. This has work. While is doesn't create a fully compliant zip file, it did work for a while.
>
>Later on, I adjusted my zip class to support parallel methods to zip and unzip with Winzip. That assumes that Winzip is installed on where it runs.
>
>Now, in order to avoid all those problems with Shell32, I would like to know if there could be an equivalent of that code so I could use something directly from the framework and not from a COM object:
>
>
>        ' Zip a file
>        Public Function Zip() As Boolean
>            Dim lcFile As String = ""
>            Dim llSuccess As Boolean = False
>            Dim lnReturn As Double = 0
>            Dim loByte(21) As Byte
>            Dim loObject As Object
>            Dim loDestinationFolder As Shell32.Folder
>            Dim loFile As Shell32.FolderItem
>            Dim loProcess As Framework.ProcessFile = New Framework.ProcessFile(oApp)
>            Dim loShellClass As Shell32.ShellClass = New Shell32.ShellClass
>            Dim loSourceFolder As Shell32.Folder
>
>            ' Reset everything
>            lError = False
>            cError = ""
>
>            ' If we want the default
>            If Not lWinZip Then
>
>                Try
>
>                    ' If the source folder does not exist
>                    If Not oApp.DirectoryExist(cSourceFolder) Then
>                        cError = "The directory " + cSourceFolder + " does not exist."
>                        lError = True
>                        Exit Try
>                    End If
>
>                    loSourceFolder = loShellClass.NameSpace(cSourceFolder)
>
>                    loByte(0) = 80 : loByte(1) = 75 : loByte(2) = 5 : loByte(3) = 6
>
>                    ' Make an empty PKZip file
>                    File.WriteAllBytes(cDestinationFile, loByte)
>
>                    loDestinationFolder = loShellClass.NameSpace(cDestinationFile)
>
>                    ' For each file
>                    For Each loObject In oFile
>                        lcFile = loObject(1)
>
>                        ' If the file does not exist
>                        If Not oApp.FileExist(cSourceFolder + "\" + lcFile) Then
>                            cError = "The file " + cSourceFolder + "\" + lcFile + " does not exist."
>
>                            ' Remove the temporary file
>                            If Not oApp.DeleteFile(cDestinationFile) Then
>
>                            End If
>
>                            lError = True
>                            Exit Try
>                        End If
>
>                        loFile = loSourceFolder.Items.Item(lcFile)
>                        loDestinationFolder.CopyHere(loFile, 20)
>                    Next
>
>                    llSuccess = True
>                Catch loError As Exception
>                    lError = True
>                    cError = loError.Message
>                End Try
>
>            Else
>
>
>Basically, the use of ShellClass allows us to zip a file using a shell approach. If someone knows something that I can use directly from the framework instead, that would be appreciated.


Have you looked at dotnetzip yet?
http://dotnetzip.codeplex.com/
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform