Sometimes we need to get file name from path location. In that there's a lot of file format. So we could in find exact file. So that we find or get filename with pattern . Here you go i gave sample code for.....
Sample Code:
// dir-----> File directory path
// filePattern -----> .xml, .doc,.....
private List getFileLocation(FilePath dir, str filePattern)
{
FilePath sFilePath;
FileName fileName;
List fileList = new List(Types::String);
System.IO.DirectoryInfo di;
System.IO.FileInfo[] fis;
System.IO.FileInfo fi;
int i;
int l;
;
sFilePath = dir;
//BP Deviation Documented
di = new System.IO.DirectoryInfo(sFilePath); // get file path directory
fis = di.GetFiles(filePattern); // filter the file based on given file pattern
l = fis.get_Length();
for (i = 0; i < l; i++)
{
fi = fis.GetValue(i);
fileName = fi.get_FullName();
fileList.addEnd(fileName);
}
return fileList;
}
Sample Code:
// dir-----> File directory path
// filePattern -----> .xml, .doc,.....
private List getFileLocation(FilePath dir, str filePattern)
{
FilePath sFilePath;
FileName fileName;
List fileList = new List(Types::String);
System.IO.DirectoryInfo di;
System.IO.FileInfo[] fis;
System.IO.FileInfo fi;
int i;
int l;
;
sFilePath = dir;
//BP Deviation Documented
di = new System.IO.DirectoryInfo(sFilePath); // get file path directory
fis = di.GetFiles(filePattern); // filter the file based on given file pattern
l = fis.get_Length();
for (i = 0; i < l; i++)
{
fi = fis.GetValue(i);
fileName = fi.get_FullName();
fileList.addEnd(fileName);
}
return fileList;
}
No comments:
Post a Comment