'Skip to the string and take other items
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));
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
