3
Answers

get files of a specific format from a directory

yamid

yamid

7y
240
1
Hi all,
I have a directory with several files in it. Some files have the following format:
"App_ct.out.1" and  "App_ct.out.2", .... 
I would like to use C# to check a directory to see if I have any file of the above format "App_ct.out.*" and get the full path of them and put them in a string array in a ascending order as the number in the extension. For example, suppose my directory has 100 of those files, I want to have a string array files[] like this:
 
files[0]=@"c:/ App_ct.out.1"
files[1]=@"c:/ App_ct.out.2" 
...
 files[9]=@"c:/ App_ct.out.10"
files[10]=@"c:/ App_ct.out.11"  
... 
 
Also if there is no file of the over format the files should give null.
 
Thank you so much.  
Answers (3)