I have the list of folder segments "c:\","user","temp","subfolder1","subfolder2"
I would like to find all items after "temp" item and join them. I have solved it using two methods: First I find an index of "temp" and then use another Linq method.
Maybe there is a Skip method that accepts not only the index but also the name? Something like this
directories.Skip("Temp").Skip(1).Take(1000)
My current code
var findIndex = directories.FindIndex(f=>f.ToLower()=="temp");
if (findIndex != -1)
{
filePath = string.Join(@"\", directories.Skip(findIndex).Skip(1).Take(1000));
}
CodePudding user response:
You can use SkipWhile:
directories.SkipWhile(x => x != "Temp").Skip(1).Take(1000)
