Reading file from zip file without extracting
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts
Page 1 of 1
Hello im trying to read images from a zip file, but i dont want to extract the zip i just want to stream the data to an array or something, does anyone know if this is possible with DotNetZip ?
I think you can do this in VB
First add references to:
System.IO.Compression
System.IO.Compression.FileSystem
Then using this code:
In the example I'm opening a zip file that contains a html file and displaying the contents of that file in a richtextbox.
Hope this helps you get started
First add references to:
System.IO.Compression
System.IO.Compression.FileSystem
Then using this code:
Code: Select all
You can read the contents of the zip file and do whatever you need to do without extracting it. Dim zipPath As String = "C:\TestFile.zip"
Dim UnzippedStream As Stream
Using archive As ZipArchive = ZipFile.OpenRead(zipPath)
For Each entry As ZipArchiveEntry In archive.Entries
If entry.FullName.EndsWith(".html", StringComparison.OrdinalIgnoreCase) Then
UnzippedStream = entry.Open
Using reader = New StreamReader(UnzippedStream)
RichTextBox1.Text = reader.ReadToEnd()
End Using
End If
Next
End Using
In the example I'm opening a zip file that contains a html file and displaying the contents of that file in a richtextbox.
Hope this helps you get started
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
CodenStuff wrote:I think you can do this in VB
First add references to:
System.IO.Compression
System.IO.Compression.FileSystem
Then using this code:Code: Select allYou can read the contents of the zip file and do whatever you need to do without extracting it.Dim zipPath As String = "C:\TestFile.zip" Dim UnzippedStream As Stream Using archive As ZipArchive = ZipFile.OpenRead(zipPath) For Each entry As ZipArchiveEntry In archive.Entries If entry.FullName.EndsWith(".html", StringComparison.OrdinalIgnoreCase) Then UnzippedStream = entry.Open Using reader = New StreamReader(UnzippedStream) RichTextBox1.Text = reader.ReadToEnd() End Using End If Next End Using
In the example I'm opening a zip file that contains a html file and displaying the contents of that file in a richtextbox.
Hope this helps you get started
What .NET version is this and what should i import ?
Any from .NET 4.0 upwards
If you go to project > add reference you can add the ones I mentioned from the list.
If you go to project > add reference you can add the ones I mentioned from the list.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
4 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023