Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu Apr 13, 2017 2:58 pm

Hi,
I created an app in C# that converts an image file (jpg/bmp/tif) to a pdf and then moves the original file to a subdirectory.
When I try to use the System.IO.File.Move method, I find the original file to be locked.
Suggestions?
Thanks in advance,

Rob Fedorchuk
System Admin
Saskpower

saskpower
 
Posts: 8
Joined: Mon Apr 03, 2017 2:40 pm

Fri Apr 14, 2017 2:34 am

Dear Saskpower,

Thanks for your inquiry.
Please dispose the image, and then use the File.Move method.
Sample code for your kind reference.
Code: Select all
            PdfDocument doc = new PdfDocument();
            PdfPageBase page = doc.Pages.Add();
            PdfImage image = PdfImage.FromFile(@"F:\image\image1.jpg");
            page.Canvas.DrawImage(image, 0, 0);
            doc.SaveToFile("10314.pdf");
            //dispose the image
            (image as PdfBitmap).Dispose();
            //move that image
            File.Move(@"F:\image\image1.jpg", @"F:\image1.jpg");

If you still have issues, please provide us with the code you were using for testing.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Sat Apr 15, 2017 9:31 am

Hello,

Have your tried the solution posted by Betsy? Has your issue been resolved?

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.PDF