During recent implementation got task to fetch the files from specified directory to import in tables using XMLPORT and I was using NAV 2017.
Now in classic version we were able to use FILE and this virtual table was giving us the list of files in specified path by using required filters and we were able to import data from multiple files.
Coming to latest version to find the files in directory I used DotNet variables as follows
From one of the folder I am fetching the filename as follows

Define the variables as follows
Name Data Type Sub type Length
gvDirectory DotNet System.IO.DirectoryInfo.’mscorlib’
gvFile DotNet System.IO.FileSystemInfo.’mscorlib’
gvArr DotNet System.Array.’mscorlib’
i Integer
In one codeunit write following program
gvDirectory:=gvDirectory.DirectoryInfo(‘E:\WorkingFolder\Target\’);
gvArr:=gvDirectory.GetFileSystemInfos();
FOR i:=0 TO gvArr.Length-1 DO
BEGIN
gvFile:=gvArr.GetValue(i);
Name:=gvFile.Name;
END;
Message(Name);

This will help in importing the multiple/sequential’s files in tables using XMLPORT.
Let me know yours feedback.
Cheers
Like this:
Like Loading...
Related
Author: Ammolh Saallvi
I'm a Dynamics NAV/Navision developer and helps partners and end-users with their NAV implementations. I do everything from third-party management advisory, training to new NAV teams, project management, training, setup and development.
Do you want to hire me to help getting your project a success? Then contact me via dropping one email from linkedin
Expertise in end-to-end development of software products from requirement analysis to System Study, Documentation and Testing. Demonstrated abilities in analyzing information system needs, evaluating end-user requirements, custom designing solutions, troubleshooting for complex information systems management. Deft at carrying out risk analysis, impact analysis, project reviews and documentation. Strong Problem solving & Technical skills coupled with confident decision making for enabling effective solutions leading to high customer satisfaction as well as low operational costs.
Certifications:-
Microsoft Certified Technology Specialist -Dynamics
Microsoft Sure Step Certified Professional
Moderator at DUG Forum
Specialties: • ERP Implementation
• Client/Server Programming
• Coding, Testing, troubleshooting and documentation.
• Database Tuning and SQL
• Database Performance
• Debugging large programs
• Project Management and Resource Management.
View all posts by Ammolh Saallvi
Hi,
I’d do it the following way:
Variables:
DirectoryInfo DotNet System.IO.DirectoryInfo
ArrayList DotNet System.Collections.ArrayList
FileName Text
Code:
DirectoryInfo := DirectoryInfo.DirectoryInfo(‘MySearchPath’);
ArrayList := DirectoryInfo.GetFiles(‘*.txt’); //Example filter on txt files only
FOREACH FileName in ArrayList DO BEGIN
MESSAGE(FileName);
END;
So we do not need to use a DotNet File Variable.
Another point: I would not recommend to use a prefix like “gv”, this is not Microsoft Styleguide compatible.
LikeLike
Nice to have your code also and gv is what my company is following for identifying the variables.
LikeLike
Amol,
This solution is exactly what I am needing. However, I get an error that says it can’t find part of the path. I am tying to access a directory from the local PC (C:\TEMP) on a system that uses an Azure-Based cloud NAV Server and SQL.
I the above calls attempting to access the C: drive of the NAV Server? If so, how can I get it to access local drives?
LikeLike