c# - .NET Collection needed to store file paths and extensions -


i have huge amount of file paths , file extensions deal :

  • each file path has 1 file extension associated it.
  • each file extensions has 1 or more file paths associated it.
  • paths unique, extensions aren't.

my goal retrieve file paths associated given file extension.

for example, if ask "mp3", i'd know paths of files extension.

now, question : c# collection should use optimally , how should use collection?

i use dictionary<string, list<string>> key extension (for example, "mp3") return list of file paths of type .mp3.

if can use linq, use single list<string> , retrieve file paths associated specific file extension this:

list<string> s = new list<string>(); s.add("c:\\documents , settings\\sound1.mp3"); s.add("c:\\documents , settings\\sound2.mp3"); s.add("c:\\documents , settings\\sound3.mp3"); s.add("c:\\documents , settings\\something1.wav"); s.add("c:\\documents , settings\\something2.exe"); s.add("c:\\documents , settings\\abc.mp3");  var mp3paths = s.where(x => string.compare(".mp3", path.getextension(x), true) == 0); var exepaths = s.where(x => string.compare(".exe", path.getextension(x), true) == 0); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -