I'm using a C# application that take a file from a path as an image:
Image.FromFile(path);
and then display it in my listview.
I have then a button that calls a method to replace this image wich is selected in the listview by another image, using this method:
public void Replace(string newImgPath)
{
if (GetImageFromPath(newImgPath) != null && GetImageFromPath(PathName) != null)
{
var Oldimg = GetImageFromPath(PathName);
var NewImg = GetImageFromPath(newImgPath);
if (NewImg.Height != Oldimg.Height)
{
NewImg = ResizeMe(NewImg, Oldimg.Height, Oldimg.Width);
}
if (File.Exists(PathName))
{
File.Delete(PathName);
}
NewImg.Save(PathName);
}
}
But i get an exception that i cannot delete this file!