Monday, December 3, 2012

Need to delete Files having more than 3 Underscores ( _ )

Try this code may help u .


void deleteFiles() 
{
DirectoryInfo objDir = new DirectoryInfo(@"D:\");
FileInfo[] objFileList = objDir.GetFiles();
foreach(FileInfo f in objFileList)
{
if (f != null)

if (f.Name.Split('_').Length > 3)
{
f.Delete();
}
}
});



No comments:

Post a Comment