linq - C# Directory.GetFiles with mask -


in c#, files specific directory matches following mask:

  • prefix "myfile_"
  • suffix numeric number
  • file extension xml

i.e

myfile_4.xml  myfile_24.xml 

the following files should not match mask:

_myfile_6.xml myfile_6.xml_ 

the code should somehing this (maybe linq query can help)

string[] files = directory.getfiles(folder, "???"); 

thanks

i not regular expressions, might -

var myfiles = file in system.io.directory.getfiles(folder, "myfile_*.xml")               regex.ismatch(file, "myfile_[0-9]+.xml",regexoptions.ignorecase) //use correct regex here               select file; 

Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -