string sPath = "c:\\inetpub\\wwwroot\\iwkoeln\\import\\";
string sFileName="";
string sFilePath="";
divContent.Visible = false;
divBanner.Visible = false;
divImageP.Visible = true;
sqlDaImage.SelectCommand.Parameters["@ID"].Value = Convert.ToInt32(sId);
sqlDaImage.Fill(dsBericht);
if(dsBericht.Tables[0].Rows.Count>0)
{
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;
}
}
imgShow.Src = "import/" + sFileName;
}
I need the pictures on the disk for speed purposes. From the DB it took too long and used almost the full bandwidth. Yesterdeay was release day for the web site and it was a killer too, at one point I was waiting 10 Minutes for the homepage to show.