Copyright Codenstuff.com 2017
Steam game giveaway
All games FREE. First come first served.
YOU NEED TO BE LOGGED IN TO USE THIS FEATURE


Register
Credits
0
Reputation
0
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.


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 ?

Image
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 all
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


You can read the contents of the zip file and do whatever you need to do without extracting it.

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 I hope you like the site and the tutorials. 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 all
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


You can read the contents of the zip file and do whatever you need to do without extracting it.

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 ?

Image
Any from .NET 4.0 upwards

If you go to project > add reference you can add the ones I mentioned from the list.

Welcome to CodenStuff.com I hope you like the site and the tutorials. Thank you for being a member of the community.



Online now

Users viewing this forum: No registered users and 1 browsing

cron