error saving file in temp directory

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.
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

error saving file in temp directory

Post by EricAriens »

Hi,

I get an error when saving a document in a temp directory.
The following code can be used to reproduce the error.
The error is System.ArgumentException, Value does not fall within the expected range.

Code: Select all

            string tmpFile;
            FileInfo fi = new FileInfo("C:\\Users\\eric\\Downloads\\Test pagina meerder paginas.pdf");
            tmpFile = Path.GetTempPath() + fi.Name;

            IPXV_Document ipxvDoc = pdfCtl.Inst.FindDocByID(pdfCtl.Doc.ID);
            ipxvDoc.Save(tmpFile, (int) PXV_DocSaveFlags.PXV_DocSave_SwitchToDest);                                             <-- Generates the error
The current document is the file as pointed in the FileInfo.

Regards
Eric Ariens
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: error saving file in temp directory

Post by Sasha - Tracker Dev Team »

Hello Eric,

Please debug your program and check the tmpFile value and post it here - probably it's invalid.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Re: error saving file in temp directory

Post by EricAriens »

Hi,

Path checked and does exists.
The file obviously not but I want to create it.
C:\Users\eric\AppData\Local\Temp\Test pagina meerder paginas.pdf

Regards
Eric
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: error saving file in temp directory

Post by Sasha - Tracker Dev Team »

Please check the Save() description and it's sample again - you can't pass string as a path parameter. Please do this for correct code work:

Code: Select all

PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)Inst.GetExtension("AFS");
PDFXEdit.IAFS_Name destPath = fsInst.DefaultFileSys.StringToName("D:\\TestFile.pdf"); //Converting string to name
Doc.Save(destPath, (int)PDFXEdit.PXV_DocSaveFlags.PXV_DocSave_NoProgress);
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
EricAriens
User
Posts: 130
Joined: Tue May 03, 2016 1:11 pm

Re: error saving file in temp directory

Post by EricAriens »

Hi,

Yep that did the trick :D

Thanks
Eric
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: error saving file in temp directory

Post by Sasha - Tracker Dev Team »

Glad that hepled :wink:
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ