String qry;
qry = "select gpid, image_url from g_product_specific order by gpid";
SqlDataAdapter da = new SqlDataAdapter(qry, con);
DataSet ds = new DataSet();
da.Fill(ds);
// convert string to bytes
System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] myByteArray = enc.GetBytes(ds.Tables[0].Rows[0]["image_url"].ToString());
System.IO.MemoryStream ms = new System.IO.MemoryStream(myByteArray);
System.Drawing.Image img = System.Drawing.Image.FromStream(ms); // Error occurs here. "parameter is not valid"
string ImageName = "abc.jpg";
string dipath = HttpRuntime.AppDomainAppPath + "My Images\\";
string serverPath = dipath + ImageName;
img.Save(serverPath);
I'm trying to download image url in database to image file to the local folder. i tried for past two days. I struggle with this. If anybody face this problem and got soultion, revert me back.
Thanks in advance.