How can I load an Image in WPF using the DotNetZip ZipEntry class.
using (ZipFile file = ZipFile.Read ("Images.zip"))
{
ZipEntry entry = file["Image.png"];
uiImage.Source = ??
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ZipEntry type exposes an OpenReader() method that returns a readable stream. This may work for you in this way:
I am not certain this will work because:
I don’t know the BitmapImage class or how to manage it, or how to create one from a stream. I may have the code wrong there.
the ZipEntry.OpenReader() method internally sets and uses a file pointer that is managed by the ZipFile instance, and the readable stream is valid only for the lifetime of the ZipFile instance itself.
The stream returned by ZipEntry.OpenReader() must be read before any subsequent calls to ZipEntry.OpenReader() for other entries, and before the ZipFile goes out of scope. If you need to extract and read multiple images from a zip file, in no particular order, or you need to read after you’re finished with the ZipFile, then you’ll need to work around that limitation. To do that, you could call OpenReader() and read all the bytes for each particular entry into a distinct MemoryStream.
Something like this: