We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

File in Use error in merging TIFF files routine

I am using the code below to merge multiple single page TIFF files together, a copy the single page TIFF files into a folder, run the routine below to merge, then proceed to the next batch, delete the prior files copied, then copy the next batch of files to be merged, etc. However, after one or 2 cycles, the delete fails as it indicates the files are still in use, I assume by the imaging routine

Any suggestions?

*** START CODE ***

Aspose.Imaging.FileFormats.Tiff.TiffImage imgAddition = null;
Aspose.Imaging.FileFormats.Tiff.TiffFrame ifrAddition = null;

Aspose.Imaging.FileFormats.Tiff.TiffImage imgOriginal = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(mPath + "\\" + Path.GetFileName((string)aSourceFiles[1]));

for (int i = 2; i <= aSourceFiles.Count; i++)
{
imgAddition = (Aspose.Imaging.FileFormats.Tiff.TiffImage)Aspose.Imaging.Image.Load(mPath + "\\" + Path.GetFileName((string)aSourceFiles[i]));
ifrAddition = Aspose.Imaging.FileFormats.Tiff.TiffFrame.CopyFrame(imgAddition.ActiveFrame);
imgOriginal.AddFrame(ifrAddition);
}

imgOriginal.Save(mPath + "\\merged.tif");

imgOriginal.Dispose();

*** END CODE ***

Hi Frank,


Thank you for considering Aspose products, and welcome to Aspose.Imaging support forum.

We will require your complete source code (most preferably a sample application) to properly analyze the problem cause on our end. For now, we suggest you to employ the Using statement to initialize the Image instances (wherever applicable) to let the garbage collector dispose-off the unused objects most efficiently.