It might help you,
public static Int32 HowManyFiles(string folderName)
{
return Directory.Exists(folderName) ? Directory.GetFiles(folderName).Count() : 0;
}
public static Int32 HowManyImageFiles(string folderName)
{
IList myList = new List<string>() { ".jpeg", ".jpg", ".gif", ".bmp" };
return Directory.Exists(folderName) ? Directory.GetFiles(folderName).Where(item => myList.Contains(Path.GetExtension(item))).Select(item => item).Count() : 0;
}
usage:
var result = HowManyFiles(@"C:\temp");
var resultWithImage = HowManyImageFiles(@"C:\temp");
:)