using System.Linq;
using System.IO;
...
string fileExtensions = ".pdf, .tif, .jpg, .bmp";
string [] fileExtensionArray =
fileExtensions.split(',').Select(e => e.Trim().ToLower()).ToArray
DirectoryInfo di = new DirectoryInfo("C:\\myDir");
FileInfo[] fileInfoArray =
di.GetFiles()
.Where(f => fileExtensionArray.Contains(f.Extension.ToLower()))
.ToArray
...
foreach( var item in fileInfoArray )
{
string fileFullPath = item.FullName;
// Perform your work with the desired file here.
}
No comments:
Post a Comment