I am sharing today a method which can help you get files in a particular path.
static container findMatchingFiles(
str _folderPath
, str _filePattern = '*.jpg*')
{
System.IO.DirectoryInfo directory;
System.IO.FileInfo[] files;
System.IO.FileInfo file;
InteropPermission permission;
container fileTypes;
Counter counter = 1;
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();
fileTypes = ['*.bmp*','*.jpeg*','*.gif*','*.jpg*','*.png*'];
while(filesCount == 0 && counter <= conLen(fileTypes))
{
_filePattern = conPeek(fileTypes,counter);
files = directory.GetFiles(_filePattern);
filesCount = files.get_Length();
counter++;
}
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;
}
No comments:
Post a Comment