简体   繁体   中英

View archive image file

我可以使用C#在PictureBox中的.zip文件中查看图像(缩略图)而不提取.zip吗?

No, you can't do this without extracting the image from the zip. You don't necessarily need to extract it into a temporary file, you could extract it into a memory stream and then create an image from that stream.

You can extract a single file from a .ZIP into a memory stream. DotNetZip is one library that can do it.

Here is a sample from their Examples page:

using (ZipFile zip = ZipFile.Read(ExistingZipFile))
{
    ZipEntry e = zip["Image.bmp"];
    e.Extract(outputStream);
}

You now have the image in a stream, which you can use to set the source of your PictureBox :

var bmp = new Bitmap(outputStream);
pictureBox.Image = bmp;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM