Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi, all

here i am using to show image using stream

my code to save
C#
System.IO.Stream fs = fuImage.PostedFile.InputStream;
                    System.IO.BinaryReader br = new System.IO.BinaryReader(fs);
                    Byte[] bytes = br.ReadBytes((Int32)fs.Length);
                    string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
                    Image1.ImageUrl = base64String;


i have no prob this one

my code to Retrive

C#
byte[] bytes = Encoding.ASCII.GetBytes(Dtab.Rows[0]["photo"].ToString());
            MemoryStream ms = new MemoryStream(bytes);
            Image1.ImageUrl = Convert.ToBase64String(ms.ToArray(), 0, ms.ToArray().Length);


it complied without error but not showing image in image control

Thanks !
Posted

1 solution

The fragment of code which is "not showing image" makes no sense at all. You retrieve some string (who knows what was stored in it?), serialize it into byte assuming it was ASCII (how can I know it was stored as ASCII?) and then serialize it into bytes, and, the worst part, encode is to base64. But base64 function of any text cannot be any URL in principle. It remains a puzzle what was you idea behind this fragment of code, better ask yourself about it.

What to do? It depends on what was stored in row 0 under the columns name "photo", was it related to any image at all or not, and it what form it was represented in the string. Again, ask yourself about it.

—SA
 
Share this answer
 
Comments
prasanna.raj 18-Aug-14 2:06am    
Thank you for carrying ....

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