I am writing a program that takes a string from a textedit box, does imagemagick voodoo on it, but when it generates it, it saves the file as foo.png and a preview panel control loads foo.png. it works fine. however, if i stay in the program, change the text, and regenerate i get an unhandled exception that gets cross with me saying the file access is denied. the file itself still gets updated, it is just the panel control.
how do i fix it?
how do i fix it?
try
{
using (MagickImage result = images.Montage(montageSettings))
{
result.Write("foo.png");
}
}
catch (Exception ex)
{
string message = "Exception type " + ex.GetType() + Environment.NewLine +
"Exception message: " + ex.Message + Environment.NewLine +
"Stack trace: " + ex.StackTrace + Environment.NewLine;
if (ex.InnerException != null)
{
message += "---BEGIN InnerException--- " + Environment.NewLine +
"Exception type " + ex.InnerException.GetType() + Environment.NewLine +
"Exception message: " + ex.InnerException.Message + Environment.NewLine +
"Stack trace: " + ex.InnerException.StackTrace + Environment.NewLine +
"---END Inner Exception";
}
Console.WriteLine(message);
}
}
// problems start here mate
// as if this gets commented out, it wont crash, but previewing is a necessity.
Preview.BackgroundImage = Image.FromFile("foo.png");
// End of problematic area