How do I create a list of filenames from a folder in C# -


i got problem when want populate array file names.

the code is:

 string [] arrays= {};  string sdira= "path of directory";   foreach (string d in directory.getdirectories(sdira))  {     foreach (string f in directory.getfiles(d, "*.*"))`enter code here`    {      int j = 0;       array[j++] = path.getfiles(f);    }   } 

when loop through array, array contains nothing :( how fill array in case? or better solution :)

solution posted on other question. eliminates need loop @ all

string [] arrays; string sdira= "path of directory";  arrays =  directory.getfiles(sdira, "*", searchoption.alldirectories).select(x => path.getfilename(x)).toarray(); 

could

arrays = directory.getfiles(sdira, "*", searchoption.alldirectories)     .where(s => (path.getextension(s).tolower() == extensiontype)).toarray(); 

if want .jpg (seemed indicated in other question) extensiontype = ".jpg"


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -