Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15628

VS 2019 Extracting specific information from an IEnumerable using LINQ?

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

Name:  2020-11-21_13-32-35.png
Views: 59
Size:  17.4 KB

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

So if I pass C:\ then it just returns list of files in root of C:\ and a list of directories in root of C:\ - 1 level only. If I pass C:\Windows then it returns list of files in root of C:\Windows and a list of directories in C:\Windows - again just the level given and no lower (or higher)

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

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

Example project attached shows exactly how the IEnumerable is filled using NTFSreader link

N.B. I want to continue using Ntfs reader and NOT use IO.Directory.GetDirectories / GetFiles as NTFS reader is much quicker and doesn't have same issue with IO permissions as it gets information directly from MFT

Anyone here got any thoughts please? Have spent some hours with Google and other forums but at a loss here - thanks

Happy to use something other than LINQ if it works better, just assumed that would be best method as querying an IEnumerable
Attached Images
 
Attached Files

Viewing all articles
Browse latest Browse all 15628

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>