Decomprimere Zip

lunedì 11 ottobre 2004 - 08.44

pecos81 Profilo | Junior Member

Buongiorno a tutti,
avendo bisogno di lavorare con gli zip, ho "approfittato" dell'articolo inserito da Giovanni Ferron. Ottimo articolo, per carità, ma anche se ho riportato tutto in vb,questo non funziona.
Per comprimere i files, ho trovato questa sub

Shared Sub ZipFile(ByVal Filename As String, ByVal strFileToZip As String, ByVal strZippedFile As String, ByVal nCompressionLevel As Integer, ByVal nBlockSize As Integer)
' If (Not System.IO.File.Exists(strFileToZip)) Then
' Throw New System.IO.FileNotFoundException("The specified file " + strFileToZip + "could not be found. Zipping aborted.")
' End If

Dim strmStreamToZip As System.IO.FileStream
strmStreamToZip = New System.IO.FileStream(strFileToZip, System.IO.FileMode.Open, System.IO.FileAccess.Read)

Dim strmZipFile As System.IO.FileStream
strmZipFile = System.IO.File.Create(strZippedFile)

Dim strmZipStream As ZipOutputStream
strmZipStream = New ZipOutputStream(strmZipFile)

Dim myZipEntry As ZipEntry
myZipEntry = New ZipEntry(Filename)
strmZipStream.PutNextEntry(myZipEntry)
strmZipStream.SetLevel(nCompressionLevel)

Dim abyBuffer(nBlockSize) As Byte
Dim nSize As System.Int32
nSize = strmStreamToZip.Read(abyBuffer, 0, abyBuffer.Length)
strmZipStream.Write(abyBuffer, 0, nSize)

Try
While (nSize < strmStreamToZip.Length)
Dim nSizeRead As Integer
nSizeRead = strmStreamToZip.Read(abyBuffer, 0, abyBuffer.Length)
strmZipStream.Write(abyBuffer, 0, nSizeRead)
nSize = nSize + nSizeRead
nSizeRead = Nothing
End While

Catch Ex As System.Exception
Throw Ex

End Try

strmZipStream.Finish()
strmZipStream.Close()
strmStreamToZip.Close()

strmStreamToZip = Nothing
strmZipFile = Nothing
strmZipStream = Nothing
myZipEntry = Nothing
abyBuffer = Nothing
nSize = Nothing

End Sub

e funziona correttamente, ma se cerco di decomprimerla con la traduzione in vb della funzione dell'articolo il file è illeggibile.
Nel mio caso specifico, comprimo un database access e quando lo decomprimo, all'apertura del file del db mi chiede una password che non c'è mai stata.
Sapete dirmi perchè?

Grazie
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5