Getting started with NAV and .Net Interop – Part 4
Once more into the breach Jeez, Part 4 already? Last time in Part 3 we imported files using streams and learned a bit more about .Net and our stamina to read boring code. The previous example was a tad bigger than the first one, but now we’ll wrap that into an even bigger example! Exampleception !! Import all files in a folder We have all done this before . When you want to import a file you make a Record variable on the File record. Filter it, loop over it, build your filename, and import it. Something like this: lv_ImportPath := 'C:\Import'; //You get this from Setup or the user of course //Filter lt_Files.SETRANGE(Path,lv_ImportPath); lt_Files.SETRANGE("Is a file",TRUE); lt_Files.SETFILTER(Name,'*.csv'); //Loop IF lt_Files.FINDSET THEN BEGIN REPEAT //Build file path and import file UNTIL lt_Files.NEXT = 0; END; I’ve always found this solution clunky when it works. Sometimes it won’t. We can do better rig...