static container Krishh_findMatchingFiles(str _folderPath, str _filePattern = '*.*')
{
System.IO.DirectoryInfo directory;
System.IO.FileInfo[] files;
System.IO.FileInfo file;
InteropPermission permission;
str fileName;
counter filesCount;
counter loop;
container mathchingFiles;
;
permission = new InteropPermission(InteropKind::ClrInterop);
permission.assert();
directory = new System.IO.DirectoryInfo(_folderPath);
files = directory.GetFiles(_filePattern);
filesCount = files.get_Length();
for (loop = 0; loop < filesCount; loop++)
{
file = files.GetValue(loop);
fileName = file.get_FullName();
mathchingFiles = conins(mathchingFiles, conlen(mathchingFiles) + 1, fileName);
}
CodeAccessPermission::revertAssert();
return mathchingFiles;
}
I placed the above method in Global class, so we can use that in your classes.
Make sure your folder should have access permissions when you are running in the batch.
static void Krishh_fetchFiles(Args _args)
{
container files;
counter loop;
str fileName;
;
//Assign the folder path with the file pattern if you want to filter by ex *.txt or k*.txt or m*.*..etc.
files = Global::Krishh_findMatchingFiles(AxdDocumentParameters::find().PaymJournalFile);
for (loop = 1; loop <= conlen(files); loop++)
{
fileName = conpeek(files, loop);
info(fileName);
}
}
{
System.IO.DirectoryInfo directory;
System.IO.FileInfo[] files;
System.IO.FileInfo file;
InteropPermission permission;
str fileName;
counter filesCount;
counter loop;
container mathchingFiles;
;
permission = new InteropPermission(InteropKind::ClrInterop);
permission.assert();
directory = new System.IO.DirectoryInfo(_folderPath);
files = directory.GetFiles(_filePattern);
filesCount = files.get_Length();
for (loop = 0; loop < filesCount; loop++)
{
file = files.GetValue(loop);
fileName = file.get_FullName();
mathchingFiles = conins(mathchingFiles, conlen(mathchingFiles) + 1, fileName);
}
CodeAccessPermission::revertAssert();
return mathchingFiles;
}
I placed the above method in Global class, so we can use that in your classes.
Make sure your folder should have access permissions when you are running in the batch.
static void Krishh_fetchFiles(Args _args)
{
container files;
counter loop;
str fileName;
;
//Assign the folder path with the file pattern if you want to filter by ex *.txt or k*.txt or m*.*..etc.
files = Global::Krishh_findMatchingFiles(AxdDocumentParameters::find().PaymJournalFile);
for (loop = 1; loop <= conlen(files); loop++)
{
fileName = conpeek(files, loop);
info(fileName);
}
}
Hi sir,
ReplyDeleteI am facing problem while uploading excel of Budget transaction line .
I am not able to upload dimension value to the AX.
Thanks in Advance