I have these two collections:
List<string> files =
Directory.GetFiles(FilePath).ToList().Select(file => new FileInfo(file).Name).ToList();
string[] dirs = Directory.GetDirectories(FilePath);
However, I’d like to add both of these to an empty dictionary, so I have a large dictionary with paths and files. The thing I am not sure of, how/where do I specify the keys?
For files, I want the filename as the key, and for the directories, I want the last directory (e.g. c in a/b/c) to be the key. I know how to get this information with FileInfo/DirectoryInfo classes, but not sure how to include this in creating a dictionary from the above?
I’m using .NET V3.5 and LINQ is fine.
Thanks
For files, you can do
for directories,