ralphtrent
Programmer
Hi
I have a class that downloads an image from a URL and save is on the local computer. What I do is then display the image. Next I would like to delete the image. But I can not seem to do that. Here is my code.
I think this code is holding a lock on the file and not releasing it, there for my delete code is not working. Any Idea's?
Thanks
I have a class that downloads an image from a URL and save is on the local computer. What I do is then display the image. Next I would like to delete the image. But I can not seem to do that. Here is my code.
Code:
//Download File
public SaveLogo(string ImageUrl, string ImageTitle)
{
_outputFile = @Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "\\" + ImageTitle + ".jpg";
try
{
StreamReader URL = new StreamReader(System.Net.WebRequest.Create(ImageUrl).GetResponse().GetResponseStream());
Image.FromStream(URL.BaseStream).Save(_outputFile ,System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch (Exception ex)
{
throw ex;
}
}
//Do other code
.
.
.
//Delete the file when member is called
public void DeleteImage(string FileName)
{
try
{
System.IO.File.Delete(FileName);
}
catch (Exception ex)
{
throw ex;
}
}
I think this code is holding a lock on the file and not releasing it, there for my delete code is not working. Any Idea's?
Thanks