Delete file fails after InsertPages

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
chavas
User
Posts: 141
Joined: Tue Mar 15, 2016 12:21 pm

Delete file fails after InsertPages

Post by chavas »

Hi,

Here is my code for InsertPages. My issue is after the operation, I need to delete the files which are merged and the files are 'inuse' for a long time so cannot delete them.

Dim m_aFiles As New List(Of String)
Dim m_Inst As PDFXEdit.PXV_Inst = Nothing
Dim m_Inst1 As PDFXEdit.IPXV_Document = Nothing
Dim m_pxcInst As PDFXEdit.IPXC_Inst = Nothing
Dim m_nID As Integer = 0
Dim m_nID1 As Integer = 0
Dim fsInst As PDFXEdit.IAFS_Inst = Nothing
Dim STATUS As PXC_PermStatus
Dim PDFFLAG As PXC_PermsFlags

Dim Doc As PDFXEdit.IPXC_Document
Doc = m_pxcInst.OpenDocumentFromFile(data.sFolder, clbk)
m_nID = m_Inst.Str2ID("op.document.insertPages", False)
Dim Op As PDFXEdit.IOperation = m_Inst.CreateOp(m_nID)
Dim Input As PDFXEdit.ICabNode = Op.Params.Root("Input")
Dim fsInst As PDFXEdit.IAFS_Inst
Dim destPath As PDFXEdit.IAFS_Name
Input.v = Doc
Dim options As PDFXEdit.ICabNode = Op.Params.Root("Options")
fsInst = m_Inst.GetExtension("AFS")
destPath = fsInst.DefaultFileSys.StringToName(strfladrs)
options("Src").v = destPath
options("PagesRange.Type").v = "Exact"
options("Position").v = Doc.Pages.Count
options("PagesRange.Text").v = strPgRg
Op.Do()
Doc.WriteToFile(path1)
Doc.Close()

System.IO.File.Delete(strfladrs).............this line throws error that file is in use. The file is released after about 40 secs. How do I delete this file? Is there a function to release the file which I am missing in my code?

Rgds
Charu
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Delete file fails after InsertPages

Post by Sasha - Tracker Dev Team »

Hello charu,

OK, try opening the IPXC_Document and passing it as the "Src" param (not the IAFS_Name parameter as you are specifying now) and after that call the Close method to the Src document. That should work.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply