fix output image not being loaded
This commit is contained in:
@@ -383,7 +383,7 @@ namespace PDFWorkflowManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Could not load preview image from Work directory." + ex, "Error loading preview image.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Could not load preview image from Work directory." + ex.Message, "Error loading preview image.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
if (Directory.Exists(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkOutDir)))
|
||||
@@ -393,23 +393,18 @@ namespace PDFWorkflowManager
|
||||
string[] strOutFiles = Directory.GetFiles(Path.Combine(txtProjectDir.Text, Properties.Settings.Default.WorkOutDir), "*.tif");
|
||||
if (strOutFiles.Length > 0)
|
||||
{
|
||||
string tempCopyPath = Path.Combine(tempDir, "preview_out.tif");
|
||||
File.Copy(strOutFiles[0], tempCopyPath, true);
|
||||
|
||||
using (var memoryStream = new MemoryStream(File.ReadAllBytes(tempCopyPath)))
|
||||
using (var memoryStream = new MemoryStream(File.ReadAllBytes(strOutFiles[0])))
|
||||
using (var bitmap = new Bitmap(memoryStream))
|
||||
{
|
||||
// Create a copy of the bitmap to ensure the file is released
|
||||
pictureBox2.Image = new Bitmap(bitmap);
|
||||
}
|
||||
// Release file handle so tempCopyPath is writeable
|
||||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
File.Delete(tempCopyPath);
|
||||
// At this point, the file is fully released
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Could not load preview image from Work\\out directory." + ex, "Error loading preview image.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Could not load preview image from Work\\out directory. " + ex.Message, "Error loading preview image.", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user