Note that there are some explanatory texts on larger screens.

plurals
  1. POUnzip a zip file in silverlight
    primarykey
    data
    text
    <p>I am trying to develop code to unzip file from the zip file in Silverlight 5. The files are in a directory within the zip file.</p> <p>I translated this code I found elsewhere from c# to VB since we are a VB shop. It is failing on the fourth line "Object reference not set to an instance of an object.". I realize now that the problem is that the third line is expecting a relative uri and I am passing it a file, but I don't know how to fix this.</p> <p>Can you tell me what is wrong with this code. I will also welcome other ideas.</p> <p>Thanks.</p> <pre><code>Public Shared Function GetZipContents(ByVal filename As String) As String() Try Dim zipStream As System.IO.Stream = New System.IO.MemoryStream() Dim zipInfo As New StreamResourceInfo(zipStream, Nothing) Dim streamInfo As StreamResourceInfo = Application.GetResourceStream(zipInfo, New Uri(filename, UriKind.Relative)) Dim fileStream As Stream = streamInfo.Stream Dim names As New List(Of String)() Dim reader As New BinaryReader(fileStream) Do While reader.ReadUInt32() = &amp;H4034B50 ' Skip the portions of the header we don't care about reader.BaseStream.Seek(14, SeekOrigin.Current) Dim compressedSize As UInteger = reader.ReadUInt32() Dim uncompressedSize As UInteger = reader.ReadUInt32() Dim nameLength As Integer = reader.ReadUInt16() Dim extraLength As Integer = reader.ReadUInt16() Dim nameBytes() As Byte = reader.ReadBytes(nameLength) names.Add(Encoding.UTF8.GetString(nameBytes, 0, nameLength)) reader.BaseStream.Seek(extraLength + compressedSize, SeekOrigin.Current) Loop ' Move the stream back to the begining fileStream.Seek(0, SeekOrigin.Begin) Return names.ToArray() Catch ex As Exception MessageBox.Show(ex.Message) Return Nothing End Try End Function </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload