ZipEntry.Extract(stream As System.IO.Stream) problem

Nov 25, 2011 at 4:58 AM
Edited Nov 25, 2011 at 5:04 AM

I have simple code:

Sub UnZipTest()

        Dim fl As XElement
        Dim ms = New MemoryStream

        Using zip = New ZipFile("")
            Dim entry = zip(0)
        End Using

        fl = XElement.Load(ms)

        Console.WriteLine("fl has {0} elements", fl.Elements.Count)

End Sub

However, XmlException error was thrown: Root element is missing. I was scratching my head about the reason of exception. I looked at help and read that "The position on the stream is not reset...". What was the reason not to reset the stream's position in Extract method when it throws an error?

P.S. Also Help says: "You may want to call stream.Seek() before calling ZipEntry.Extract()". Why "before", when should be "after"?