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.
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.
2 the second error is on a line after the loop - "If (s.Crc32 <> 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
The code is as copied from this link http://cheeso.members.winisp.net/DotNetZipHelp/html/4ef6405c-33ff-a8aa-1731-def3ec5cac24.htm
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
PS I have in my real program edited the references to a file and the correct zip name, the only addition is the password.
Thankyou
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 > 0)
If (s.Crc32 <> 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 <> e1.UncompressedSize) Then
Throw New Exception(String.Format("We read an unexpected number of bytes. ({0}!={1})", totalBytesRead, e1.UncompressedSize))
End If
End Using
End Using