.net - c# how to get files name into a specific folder which have a specific patter -


i have folder contains these files:

erb3pcustsexport-303_20080318_223505_000.xml erb3pcustsexport-303_20080319_063109_000_empty.xml erb3pcustsimport-303_20080319_123456.xml erb3pdelcustsexport-303_20080319_062410_000.xml erb3presosexport-303_20080318_223505_000_empty.xml erb3presosexport-303_20080319_062409_000.xml 

i care files have custsexport word in names.

my question:

how these files?

what have tried:

i got folder name app settings section in app.config this:

string folderpath = configurationmanager.appsettings["xmlfolder"]; 

then got file names this:

foreach (string file in directory.enumeratefiles(folderpath, "*.xml")) {  } 

my problem:

in way, got files. however, interested in files have custsexport in names.

could me please?

note:

i working on .net 4.5

many thanks

try this:

foreach (string file in directory.enumeratefiles(folderpath, "*custsexport*.xml")) {  } 

or can use regex:

regex reg = new regex(@".*custsexport.*\.xml",regexoptions.ignorecase);  var files = directory.getfiles(yourpath, "*.xml")                      .where(path => reg.ismatch(path))                      .tolist(); 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -