Example:
File format may be like XXX_123_253_2175_216.html Irrespective of file format based on Underscores we need to delete ?
Solution:
Private void deleteFiles()
{
DirectoryInfo objDir = new DirectoryInfo(@"C:\");
FileInfo[] objFileList = objDir.GetFiles();
foreach(FileInfo f in objFileList)
{
if (f != null)
if (f.Name.Split('_').Length > 3)
{
f.Delete();
}
}
}
and Later I have added on more requiremnet in the about CODE LIKE this
File having similar fast name should delete
Extra condition
if(f.name.startswith)
{
//code
}
Comments
Post a Comment