An unhandled exception of type System.IO.IOException
occurred in mscorlib.dll
Additional information: The process cannot access the file pathOfMyFile
because it is being used by another process.
This is the error I get when reaching File.Delete
My code looks like this:
File.Copy(frompath, topath1);
File.Copy(frompath, topath2);
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
File.Delete(frompath);
frompath
is a path to a .png image.
What can I do to make this work?