Deleting temporary file
-
hey guyz how can i delete the temporary file that i created, whenever i retrieved the image saved in my database.. it keeps on growing..i hope u can help me regarding these... here is the code string strfn = Convert.ToString(DateTime.Now.ToFileTime()); FileStream fs=new FileStream(strfn,FileMode.CreateNew,FileAccess.Write); fs.Write(imageByte,0,imageByte.Length); fs.Flush(); fs.Close(); picBox.Image = Image.FromFile(strfn);
-
hey guyz how can i delete the temporary file that i created, whenever i retrieved the image saved in my database.. it keeps on growing..i hope u can help me regarding these... here is the code string strfn = Convert.ToString(DateTime.Now.ToFileTime()); FileStream fs=new FileStream(strfn,FileMode.CreateNew,FileAccess.Write); fs.Write(imageByte,0,imageByte.Length); fs.Flush(); fs.Close(); picBox.Image = Image.FromFile(strfn);
System.IO.File.Delete(...)
-
hey guyz how can i delete the temporary file that i created, whenever i retrieved the image saved in my database.. it keeps on growing..i hope u can help me regarding these... here is the code string strfn = Convert.ToString(DateTime.Now.ToFileTime()); FileStream fs=new FileStream(strfn,FileMode.CreateNew,FileAccess.Write); fs.Write(imageByte,0,imageByte.Length); fs.Flush(); fs.Close(); picBox.Image = Image.FromFile(strfn);
Hi, FromFile keeps the file locked. Replace the last line picBox.Image = Image.FromFile(strfn); by the following (approx):
Bitmap bm = Image.FromFile(strfn);
picBox.Image=new Bitmap(bm);
bm.Dispose();
File.Delete(strfn);:)
Luc Pattyn
try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }
-
hey guyz how can i delete the temporary file that i created, whenever i retrieved the image saved in my database.. it keeps on growing..i hope u can help me regarding these... here is the code string strfn = Convert.ToString(DateTime.Now.ToFileTime()); FileStream fs=new FileStream(strfn,FileMode.CreateNew,FileAccess.Write); fs.Write(imageByte,0,imageByte.Length); fs.Flush(); fs.Close(); picBox.Image = Image.FromFile(strfn);