soooo... writing tool task collect xmls on servers based on parameters.
here's code have far:
private list<string> getlistxmls(string strpath, list<string> colctnames) { string regexexpr = "\\\\\\\\" + strstager + "\\\\appli\\\\" + strenvir + "\\\\[a-za-z]{3}\\\\bin\\\\"; if(colctnames == null) { list<string> xmlcolct = directory.getfiles(strpath, "*.*", searchoption.alldirectories) .where(x => regex.ismatch(x, regexexpr, regexoptions.ignorecase) && x.tolower().contains("msgtrait") && x.endswith(".xml")) .tolist(); return xmlcolct; } else { list<string> xmlcolct = directory.getfiles(strpath, "*.*", searchoption.alldirectories) .where(x => regex.ismatch(x, regexexpr, regexoptions.ignorecase) && x.tolower().contains("msgtrait") && x.endswith(".xml")) .tolist(); list<string> finallist = new list<string>(); foreach (string strfich in xmlcolct) { if (colctnames.any(item => strfich.tolower().contains(item.tolower()))) { finallist.add(strfich); } } return finallist; // include kind of linq method want instead of stripping down list... } }
basically need files on server match abn_msgtrait.xml
. need if user seeking orl
, uqm
or blablabla
, method get needed list instead of stripping down results need. bear in mind list xmlcolct
list of paths may contain orl
name in this: orl_msgtrait.xml
.
so question is: there way merge foreach i'm doing in linq request avoid having retrieve xmls , strip unwanted ones?
list<string> xmlcolct = directory.getfiles(strpath, "*.*", searchoption.alldirectories) .where(x => regex.ismatch(x, regexexpr, regexoptions.ignorecase) && x.tolower().contains("msgtrait") && x.endswith(".xml") && colctnames.any(item => x.tolower().contains(item.tolower()))) .tolist();
but if using regex can add that:
- it ends ".xml"
- contains "msgtrait" @ name area
- and
any
partstring.join
in order form pattern optional values ofcolctnames
Comments
Post a Comment