Public · Protected · Private
Get list of files in a directory with different file extentions
Type: Public  |  Created: 2012-06-11  |  Frozen: Yes
« Previous Public Blog Next Public Blog »
Comments
  • This 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();
    2012-06-11 11:43
This blog is frozen. No new comments or edits allowed.