Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

c# loop though dirctory getfilenames and add them to Dictionary only if they contain certin strings

$
0
0

ok what i want to do is loop though a directory and loop for certin key words 

like 

idle 

adsup

adsdown

and create a Dictionary and add the right filename to the right key this is a list of files i need to get names for

i have looped though the file 

            string[] files = Directory.GetFiles(@"D:\steam\steamapps\common\Call of Duty Black Ops III\xanim_export\elfenliedtopfan5_anims\elf_ghost_honeybadge");
            foreach (string file in files)
            {

            }

and in the foreach i want to find certin parts of the file names like sprint_in  ( and when found it adds just the filename ) to a Dictionary something like this a set key and get the value based on the filename so like this

old_wep.Add("IDLE",filename with idle string founds get put here)

and do that for all the files in this folder but not sure how to loop though file look for a string and get them to be added into a 

Dictionary with a key set like idle and getting the value to be the elf_cp_ghost_hb_idle and so on for the rest of the files 


Viewing all articles
Browse latest Browse all 2535

Trending Articles



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