我有檔案夾段串列,"c:\","user","temp","subfolder1","subfolder2"
我想在專案后查找所有專案"temp"并加入它們。我已經使用兩種方法解決了它:首先我找到一個“temp”索引,然后使用另一種 Linq 方法。
也許有一個 Skip 方法不僅接受索引而且接受名稱?像這樣的東西
directories.Skip("Temp").Skip(1).Take(1000)
我當前的代碼
var findIndex = directories.FindIndex(f=>f.ToLower()=="temp");
if (findIndex != -1)
{
filePath = string.Join(@"\", directories.Skip(findIndex).Skip(1).Take(1000));
}
uj5u.com熱心網友回復:
您可以使用SkipWhile:
directories.SkipWhile(x => x != "Temp").Skip(1).Take(1000)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/422285.html
標籤:
