Extracting specific information from IEnumerable using LINQ?

  • Thread starter Thread starter wingers
  • Start date Start date
W

wingers

Guest
Hi

I have an IEnumerable which contains file and directory information - example below of its contents:-


I want to extract specific information from this IEnumerable and am assuming LINQ is the best route

I want a list of files and a separate list of directories in a given path - but just that level, so not including sub directories etc

The lists just need to contain the FullName of each file / directory and nothing else

The Attributes value contains Directory if a directory so I can use that to easily determine if a file or a directory using something similar to below

Dim dirs2 = nodes.Where(Function(n) n.FullName.StartsWith(path) And n.Attributes = Attributes.Directory)
Dim files2 = nodes.Where(Function(n) n.FullName.StartsWith(path) And n.Attributes <> Attributes.Directory)


But I am stuck on how I just return the FullName value - AND - how to just return one level

Anyone here got any thoughts please?



Darren Rose

Continue reading...
 
Back
Top