I'm trying to get list of files from a directory in D365 Business central , because in the AL
language DotNet
var is not supported, so i don't know how can i get those files paths.
In my requirement i know the path of folder but need to get actual files paths in that folder.
Ex: Folder is E:\Dynamically\
But i want to get files path like:
E:\Dynamically\1.txt
E:\Dynamically\2.txt
E:\Dynamically\3.txt
I tried to search inbuilt function in Codeunit 419
("File Management"), and tried to get using Azure function. I am adding my code for get file from that directory but it is for one file.
action("Import Files")
{
ApplicationArea = All;
Image = Import;
trigger OnAction();
var
FromFile: Text;
FileMgt: Codeunit "File Management";
begin
Init();
Message(FileMgt.GetExtension('E:\Dynamically\' +
Format(GetFileName)));
FromFile := 'E:\Dynamically\' + Format(GetFileName);
"Attached File".Import(FromFile);
"Attched File Name" := Format(GetFileName);
"Attached file Extension" :=
FileMgt.GetExtension(Format(GetFileName));
Insert(true);
MESSAGE('Successfully Import.');
end;
}
Here's the result of my import File code.