Musings
Public · Protected · Private
Get list of files in a directory with different file extentions
-
2012-06-11 11:43This gives list of filenames string[] filesindirectory = Directory.GetFiles(Server.MapPath("~/Images")) ; This gives filtered list of files of given extensions. string[] filesindirectory = Directory.GetFiles(Server.MapPath("~/Images")) .Where(f => ( (f.ToLower().EndsWith(".jpg")) || (f.ToLower().EndsWith(".png")) || (f.ToLower().EndsWith(".gif")) || (f.ToLower().EndsWith(".ico")) ) ).ToArray();
This blog is frozen. No new comments or edits allowed.