Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi every body,

In my ASP.NET project,

I would like to save an image in stream instead of specific path and put this image from the stream into imageUrl property of an Image control.

Like the code:
C#
System.Drawing.Bitmap bitmap= new System.Drawing.Bitmap(ImagePath);        
bitmap.Save(MyStream, System.Drawing.Imaging.ImageFormat.Jpeg);        
MyIamgeControl.ImageUrl = MyStream;
Posted
Updated 6-Nov-11 0:20am
v2

You can not assign Stream object to ImageUrl property of Image control is simply bacuase it's Type is string.

However you can write your custom HttpHandler which will return Image Url for your dynamic stream.

http://stackoverflow.com/questions/46788/how-to-bind-a-memorystream-to-aspimage-control
 
Share this answer
 
No, it doesn't work like that. A stream is a temporary object existing only in the memory space of your application - it can't be assigned as a URL because it is a transitory object: it can be destroyed as soon as myStream goes out of scope - which could be at the end of the method, or could be when your page load has completed.

What are you trying to achieve that you think you need this?
 
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