Hi ,
Refer below code which will fetch the filename from Directory (FilePath) based on Current Company Code
static container findMatchingFiles(
str _folderPath
, str _filePattern = '.txt')
{
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();
//BP Deviation Documented
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;
}
static FileName fetchFiles(Args _args)
{
container files;
counter loop;
FileName fileName;
str entityId;
Filename filepathVal;
Filename fileType;
filename fileNameString;
;
entityId=strLfix('E'+curext(),7,'0');
files = DNT_DatabasicsUpload::findMatchingFiles(#FilePath, entityId+'*.txt');
for (loop = 1; loop <= conlen(files); loop++)
{
filename= conpeek(files, loop);
return filename;
}
return #FilePath;
}
Happy Daxing...............
Refer below code which will fetch the filename from Directory (FilePath) based on Current Company Code
static container findMatchingFiles(
str _folderPath
, str _filePattern = '.txt')
{
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();
//BP Deviation Documented
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;
}
static FileName fetchFiles(Args _args)
{
container files;
counter loop;
FileName fileName;
str entityId;
Filename filepathVal;
Filename fileType;
filename fileNameString;
;
entityId=strLfix('E'+curext(),7,'0');
files = DNT_DatabasicsUpload::findMatchingFiles(#FilePath, entityId+'*.txt');
for (loop = 1; loop <= conlen(files); loop++)
{
filename= conpeek(files, loop);
return filename;
}
return #FilePath;
}
Happy Daxing...............