Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
hi friends
i have store image in byte in database and now problem is how to fetch and display image in byte format
thanks
Posted
Comments
[no name] 24-Jun-13 10:08am    
There are hundreds of examples out there that do exactly this. What have you tried? Anything at all> And, what is the problem with the code that you have written?
Nelek 24-Jun-13 10:24am    

1 solution

You have to use file stream to convert byte array to file

//-------------------------------------------------------
 byte[]  yResult ; // retrive byte array from database and store in this
 string strFileName ; // file name

                                    //-------------------------------------------------------
     if (yResult.Length > 0)
     {
                                        
     FileStream fs = File.Create(System.IO.Path.GetTempPath() + "\\" + strFileName, yResult.Length, FileOptions.None);
                                        fs.Write(yResult, 0, yResult.Length);
                                        fs.Close();
                                        fs = null;
                                        ProcessStartInfo pf = new ProcessStartInfo(System.IO.Path.GetTempPath() + "\\" + strFileName);
                                        Process.Start(pf);
                                        //-------------------------------------------------------
                                    }
 
Share this answer
 
v2

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