0
Soooo ...私はタスクをパラメータに基づいてサーバー上でxmlsを収集するツールを書いています。ここでlinqどこに交差が含まれています
は、私が持っているコードは、これまでのところです:
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 some kind of linq method to get only what I want instead of stripping down the list...
}
}
基本的に必要がABN_msgTrait.xml
に一致するサーバー上の任意のファイルを取得することです。ユーザーがORL
、UQM
またはBLABLABLA
のみを検索している場合は、すべての結果を必要なものを削除するのではなく、にが必要です。リストxmlColct
は、ORL
という名前を含む可能性のあるパスのリストです(ORL_msgtrait.xml
)。
私の質問は:foreachを私がlinq要求で行っている方法をマージするを回避するは、すべてのxmlsを取得し、不要なものを取り除かなければならないのですか?
質問は不明ですか?あなたは実際にそこにいないことを実際に望んでいますか? –
どうしたのですか? – itsme86
Ooh!ごめんなさい!私の質問を編集します。 – hsim