Hi,
I have many images in a database and I need to save them to an image file before I show them in a web page.
Can anyone tell me how this is done?
Thanks,
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
LeePosted Jan 12, 2006, 6:07 AM
[CODE]
if(!File.Exists(dsBericht.Tables[0].Rows[0]["strImagePicName"].ToString()))
{
baImage = (byte[])dsBericht.Tables[0].Rows[0]["imgImagePic"];
try
{
sFileName =
dsBericht.Tables[0].Rows[0]["strImagePicName"].ToString();
if(sFileName.IndexOf("wwwroot")<=0)
{
sFilePath = sPath + sFileName;
}
else
{
int iWeg = sFileName.LastIndexOf("\\");
sFileName = sFileName.Substring(iWeg, sFileName.Length - iWeg);
sFilePath = sPath + sFileName;
}
FileStream fs = new FileStream(sFilePath, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(baImage);
bw.Close();
fs.Close();
}
catch(Exception ex)
{
string sError = ex.Message;
}
}
[/CODE]