Using archive As IO.Compression.ZipArchive = IO.Compression.ZipFile.Open(zipFullFilename, IO.Compression.ZipArchiveMode.Update)
Dim zipEntry As IO.Compression.ZipArchiveEntry = archive.CreateEntry("abc.jpg")
Using writer As IO.StreamWriter = New IO.StreamWriter(zipEntry.Open())
' Add an existing image file c:\xyz.jpg to the zipFullFilename
End Using
End Using
Using archive As IO.Compression.ZipArchive = IO.Compression.ZipFile.Open(zipFullFilename, IO.Compression.ZipArchiveMode.Update)
[COLOR=#000000][FONT=Consolas] archive.CreateEntryFromFile("[/FONT][/COLOR][COLOR=#000000]c:\xyz.jpg"[/COLOR][COLOR=#000000][FONT=Consolas], [/FONT][/COLOR][COLOR=#A31515][FONT=Consolas]"[/FONT][/COLOR][COLOR=#000000]xyz.jpg[/COLOR][COLOR=#A31515][FONT=Consolas]"[/FONT][/COLOR][COLOR=#000000][FONT=Consolas], [/FONT][/COLOR]IO.Compression.[COLOR=#000000][FONT=Consolas]CompressionLevel.Fastest)[/FONT][/COLOR]
End Using
You need to import the namespace, see code example: ZipFileExtensions.CreateEntryFromFile Method (ZipArchive, String, String, CompressionLevel) (System.IO.Compression)
I think CreateEntryFromFile is what i need to use, but after i typed archive. there is no CreateEntryFromFile. It is some zipFileExtensions class
VB.NET:Using archive As IO.Compression.ZipArchive = IO.Compression.ZipFile.Open(zipFullFilename, IO.Compression.ZipArchiveMode.Update) [COLOR=#000000][FONT=Consolas] archive.CreateEntryFromFile("[/FONT]c:\xyz.jpg"[FONT=Consolas], [/FONT][/COLOR][COLOR=#A31515][FONT=Consolas]"[/FONT][/COLOR][COLOR=#000000]xyz.jpg[/COLOR][COLOR=#A31515][FONT=Consolas]"[/FONT][/COLOR][COLOR=#000000][FONT=Consolas], [/FONT][/COLOR]IO.Compression.[COLOR=#000000][FONT=Consolas]CompressionLevel.Fastest)[/FONT][/COLOR] End Using
Byte array. You need all the data for the whole ZIP file. Load that data into a MemoryStream and then create a ZipArchive from that stream. You can then index the Entries property to get a ZipArchiveEntry. Open that to get a Stream and then use that however you like, e.g. pass it to Image.FromStream to get an Image.MemoryStream if you haven't already got a Byte array from your database. Getting the data from the database is the same as it would be for any data, so image files in ZIP files is irrelevant to that. Likewise, creating a MemoryStream is the same no matter where the data comes from or is going to. This is how you simply things such that you can find existing help on the web. If you try to find information on a process that involves multiple steps then you're less likely to be successful, because someone else would need to have done all the exact same steps. If you look for help on one step at a time, you're far more likely to find information.