vb.net - Check file against multiple extensions? -



vb.net - Check file against multiple extensions? -

i'm wondering if possible check if file matches list of set extention. @ moment have working code checks file see if has .txt .jpg or .mp3

example

if (path.getextension(f).tolower() = ".txt") ' it's .txt file ' msgbox("i txt document") b.image = my.resources.text_img elseif (path.getextension(f).tolower() = ".jpg") b.image = my.resources.img_img else b.image = my.resources.folder_img end if

this code set image shortcut. want able check if file matches more txt .doc .log video types mp4 avi mpg. sound types mp3 ogg flacc acc

tried, failed

elseif (path.getextension(f).tolower() = ".jpg" & ".png" & ".jpeg" & ".tiff") b.image = my.resources.img_img end if

is possible don't want add together 100+ extension each have own if statements. give thanks in advanced. -dan

if want avoid dictionary route (for no real reason, other beingness alternative method), can utilize in-line array check each grouping of extensions.

dim extension = path.getextension(f).tolower if {".txt"}.contains(extension) b.image = my.resources.text_img elseif {".jpg", ".png", ".tif"}.contains(extension) b.image = my.resources.img_img else b.image = my.resources.folder_img end if

i'm sure there valid , aesthetically pleasing methods using regex , sorts of linq or other weird ways of doing it!

vb.net visual-studio visual-studio-2013

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -