Hi ALL,
I have an question about open files in Navision. I have a Codeunit which used to import XMLport.
TestFile.OPEN('C:\Output\PO1.xml');
TestFile.CREATEINSTREAM(TestStream);
XMLPORT.IMPORT(50003,TestStream);
Besides PO1.xml, there are also other xml eg PO2.xml, PO3.xml, etc in the Output folder. And what I want to do is to import all *.xml files in the Output folder to Navision, but I don't know exactly how many xml files will be in the folder and the file names of each files. I want to make this codeunit to be able to open and read all the xml file in the Output folder so that I can put this Codeunit in the Job Scheduler and let it run regularly.
Does anyone have some ideas?
Comments
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
Thanks for this post.
I tried this but I have to refer the shared path for the files.
Above code try to fetch the files from Local system.
Any Suggestion ?
Thanks,
Ahmedabad, Gujarat, India
E Mail : ravi.thakkar@hotmail.com
RIS Plus, LLC
Array: https://msdn.microsoft.com/en-us/library/system.array(v=vs.110).aspx
Directory.GetFiles: https://msdn.microsoft.com/en-us/library/system.io.directory.getfiles(v=vs.110).aspx
Works like a charm, even with UNC paths, only restriction is that the searchPattern parameter does not support RegEx.
I have tried something similar to Timo, I receive this problem however:
any ideas on how to solve this?
Hopefully, the Image has came through
Thanks
Could you possibly elaborate? My issue occurred whenever I tried to open the folder (known after debugging). I should have mentioned this beforehand, apologies.
Thanks,
David
Does the user under which NAV server is running have write permission to the share where the files are located?
You can use the solution that Timo_Lässer gave above.
Also, check if you can access the folder on NAV server to guarantee that the folder can be accessed from server to server (if this is the case)
The only issue is you might have to use the shared folder ip adress as server name, eg: \\111.111.111.1\sharefoldername
then you should check:
1) Is it run by jobqueue? If so, give jobqueue user acess to the folder
2) Is it run by user when clicking a btn? If so you need to give folder access or get a way to run the jobqueue entry when the User press the btn.
Did this help you a bit more?
cheers