Posted: Tue Jun 14, 2005 1:23 am Post subject: Reading all the files in a folder from Navision programming?
Hi All,
We can read a file from a file folder and import the data into Navision. This is normally achievable by using dataport and providing the path in the filename property. (which is hardcoded ).
However i do not want to use hardcoded file name , instead wants to read the available fiels in the specified file folder ( Only the folder name and path are fixed not the file name ) and also if there are 'n' no of files existing in the above folder then i have to read all the files one by one and import the data in each file into Navision.
All we want to do is .. read all the files put in this file folder and read one file by another and import the data into Navision thru dataport..
Is this achievable in Navision using any File/System commands ? If so how ???
Is it possible to execute any shell program / dos commands directly from
Navision to get this.??
Kindly help.
0
Comments
Microsoft Dynamics NAV Developer since 1997
MSDynamics.de - German Microsoft Dynamics Community - member of [clip]
I have found this thread using the search but I am hoping someone can give further help. I am very much a beginner.
I too want to import, using a DataPort, many text files from a set drive and path location but with unknown txt file names.
Using help from other threads I have replaced the dataport property of FileName with a variable and imported a single (known) file into my dataport. This bit works fine.
Currently my code is simply I have a single local variable text of MyFileName.
So now I want to go to the next stage of looping through the unkown text files. I want to try the code from Timo Lässer stated in the above reply.
Does this code go into the datport OnPreDataport() trigger?
Also, does it "replace" the work done by the dataport and do I have to change any dataport properties to match?
I am having trouble understanding how these two lines work
What I mean is how does "Is a file" work in this context?
Finally, when finished I would like the dataport to run when the form is opened and on a button update, although I am OK with this is principle, how can I call a dataport in code?
Hope I have not "gone" on too much and thanks in advance for all help.
Regards,
SteveA
You probably want to call your dataport from a codeunit that contains the loops and sets the import filename before running the dataport.
I'm not sure about this, but chances are Is a File lets you know if the pathname you have selected Is a file, or a folder.
I did not understand how to connect to the virtual table 2000000022, so I can now import a single file.
As you pointed out I need to call my dataport from outside to import multiple files. Do you know how to do this?
I would like to call it from a form open event and from a "refresh" button on the same form