Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I want to set picture box from zip file without extract zip. my code:
C#
ZipFile zip = new ZipFile("data.zip");
using (Stream s = zip["p3.png"].OpenReader())
{
    picturebox.ImageLocation = s.ToString();
}

Picture Box Show error image.
Posted

Are you using Image control or PictureBox? You have posted the question with ASP.NET tag but I think picture box is used in winform applications and not in web applications or ASP.NET.

If you are using windows application, use the Image property instead of ImageLocation. Try the following process:

Create a Bitmap object from the image in your stream.

Then use this Bitmap object to set the Image property of your picture box.

Here are some more details:

http://msdn.microsoft.com/en-us/library/system.windows.forms.picturebox.image(v=vs.110).aspx[^]
 
Share this answer
 
Comments
Volynsky Alex 4-Apr-14 17:27pm    
+5!
Er. Puneet Goel 5-Apr-14 4:34am    
great !!
First Solution is Good. correct code:
C#
ZipFile zip = new ZipFile("data.zip");
using (Stream s = zip["p3.png"].OpenReader())
{
    Bitmap bitmap= new Bitmap(s);
    PictureBox picturebox.Image = bitmap;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900