1
Vote

ZipException was unhandled WP7

description

Private Sub UnZip(ByVal filename As String, ByVal folderpath As String)
    Dim store As IsolatedStorageFile = IsolatedStorageFile.GetUserStoreForApplication()
    Dim ZipStream As New ICSharpCode.SharpZipLib.Zip.ZipInputStream(store.OpenFile(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read))
    Dim TheEntry As ICSharpCode.SharpZipLib.Zip.ZipEntry = ZipStream.GetNextEntry()
    Do Until TheEntry Is Nothing
        Dim data(1024) As Byte
        Dim fileNameUnzipped As String = folderpath & "\" & TheEntry.Name.ToString()
        Dim newfs As New IsolatedStorageFileStream(fileNameUnzipped, System.IO.FileMode.Create, System.IO.FileAccess.Write, store)
        Dim bw As New System.IO.BinaryWriter(newfs)
        Dim buffer(1024) As Byte
        Dim length As Integer
        Dim dataToRead As Long
        dataToRead = TheEntry.Size
        While dataToRead > 0
            length = ZipStream.Read(buffer, 0, 1024)
            bw.Write(buffer, 0, length)
            ReDim buffer(1024) ' Clear the buffer 
            dataToRead = dataToRead - length
        End While
        bw.Close()
        newfs.Close()
        TheEntry = ZipStream.GetNextEntry() ' <--- Error EOF in header
    Loop
    ZipStream.Close()
    store.DeleteFile(filename)
End Sub

file attachments

comments