Link to home
Start Free TrialLog in
Avatar of kenshaw
kenshaw

asked on

need a VB6 zipping component adn a compatible .net one

I have a vb6 client that needs a SMALL dll to use to zip some files (i just want minimal zip functionality) - but I also need a compatible .net component to run on the server side to decompress the files compressed on the client.

does anyone know any?  Xceed have good libraries - but their client side zip ActiveX is 500 KB - which is way too big
Avatar of Matti
Matti
Flag of Finland image

Hi!

If the need is unzip only then:
ftp://ftp.info-zip.org/pub/infozip/WIN32/unz552dN.zip

There is VB sample code how to use this dll.


Matti
Avatar of kenshaw
kenshaw

ASKER

no - i need to zip and unzip
ASKER CERTIFIED SOLUTION
Avatar of hes
hes
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kenshaw

ASKER

but thats only for VB6 - then i need somethign for .net on the server side

aren't there issues with getting different zip libraries to interoperate?  thats why i thought it was a good idea to get two components from one vendor...
what if you call zip via the shell command...
Hi Kenshaw,

I don't understand why you say hes's dlls are only for VB6. They are just some WIN32 DLLs, and it's obvious that you can use them with VB.net as well.
Avatar of kenshaw

ASKER

hmm... but its not managed code - and its not going to scale well on a webserver - which is why i want a .net native component for the server side.

i can hack it up using those dll's sure... but its not going to scale well or safely
'For XP+ OS
'sSource - can be file or folder
'sDest - zip file path

Public Function vbZIP(ByVal sSource As String, ByVal sDest As String) As Boolean
   Dim lAttr As Long, lInitialLength As Long
   lAttr = GetFileAttributes(sSource)
   If lAttr = -1 Then Exit Function
   
   Dim sZipHeader As String
'   sZipHeader = Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, Chr(0))
   sZipHeader = "PK" & Chr(5) & Chr(6) & String(18, Chr(0))
   If Dir(sDest) <> "" Then Kill sDest
   Dim nFile As Integer
   nFile = FreeFile
   Open sDest For Output As #nFile
      Print #nFile, sZipHeader
   Close #nFile
   lInitialLength = FileLen(sDest)
   Dim oShell, oSource
   Set oShell = CreateObject("Shell.Application")
  'Copy the file(s) to the compressed folder
   If (lAttr And vbDirectory) = vbDirectory Then
      Set oSource = oShell.NameSpace(CVar(sSource)).Items
   Else
      Set oSource = oShell.NameSpace(CVar(GetParentFolder(sSource))).ParseName(GetFileTitle(sSource))
   End If
   If Not oSource Is Nothing Then
      oShell.NameSpace(CVar(sDest)).CopyHere oSource, &H615
   Else
      GoTo ErrZip
   End If
   Do While Dir(sDest) = ""
      DoEvents
      Sleep 100
   Loop
   On Error Resume Next
   Do While FileLen(sDest) = lInitialLength
      DoEvents
      Sleep 100
   Loop
  'wait for lock to release
   On Error Resume Next
   Do
'Attempt to open the file, this causes an Err 70,
'Permission Denied when the file is already open
      nFile = FreeFile
      Open sDest For Append As #nFile
      Close #nFile
      If Err = 0 Then Exit Do
      Sleep 100
      Err.Clear
   Loop
   vbZIP = True
ErrZip:
   Set oSource = Nothing
   Set oShell = Nothing
End Function