Note that there are some explanatory texts on larger screens.

plurals
  1. PODotNetZip extracting to stream problems using provided code sample
    text
    copied!<p>I am atempting to open a zip file and extract a password and 256 AES encrypted text file into a stream which I can read WITHOUT puting a copy of the text onto the drive. If I understand what I want to do correctly, using a stream will acomplish that. Im not very experianced with code so Im using example that I found on the DontNetZip site which is bellow. The problem is 2 fold, it throws 2 errors when processing, I was hoping that someone can help with these.</p> <p>1 the first error occure on the 3rd line - "Using s As CrcCalculatorStream = e1.OpenReader" the error is ' Object reference not set to an instance of an object. ' I have tried declearing and new and still it crashes on that line.</p> <p>2 the second error is on a line after the loop - "If (s.Crc32 &lt;> e1.Crc32) Then" and the error is a squigly line under s.Crc32 and it sais that Crc32 is not a memeber of CrcCalculatorStream , a similar error under the e1.Crc32 which isnt a member of Ionic.zip.zipEntry</p> <p>The code is as copied from this link <a href="http://cheeso.members.winisp.net/DotNetZipHelp/html/4ef6405c-33ff-a8aa-1731-def3ec5cac24.htm" rel="nofollow">http://cheeso.members.winisp.net/DotNetZipHelp/html/4ef6405c-33ff-a8aa-1731-def3ec5cac24.htm</a></p> <p>Can someone help me get through the code to see if I can get the result that Im after , that is to have the content of the text file in a string so that I can read it </p> <p>PS I have in my real program edited the references to a file and the correct zip name, the only addition is the password.</p> <p>Thankyou</p> <pre><code>Using zip As New ZipFile(ZipFileToRead) Dim e1 As ZipEntry = zip.Item("Elevation.mp3") Using s As Ionic.Zlib.CrcCalculatorStream = e1.OpenReader(password) Dim n As Integer Dim buffer As Byte() = New Byte(4096) {} Dim totalBytesRead As Integer = 0 Do n = s.Read(buffer, 0, buffer.Length) totalBytesRead = (totalBytesRead + n) Loop While (n &gt; 0) If (s.Crc32 &lt;&gt; e1.Crc32) Then Throw New Exception(String.Format("The Zip Entry failed the CRC Check. (0x{0:X8}!=0x{1:X8})", s.Crc32, e1.Crc32)) End If If (totalBytesRead &lt;&gt; e1.UncompressedSize) Then Throw New Exception(String.Format("We read an unexpected number of bytes. ({0}!={1})", totalBytesRead, e1.UncompressedSize)) End If End Using </code></pre> <p>End Using</p>
 

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