h1.post-title { color:orange; font-family:verdana,Arial; font-weight:bold; padding-bottom:5px; text-shadow:#64665b 0px 1px 1px; font-size:32px; } -->

Pages

Delete files base on character

Good Afternoon!
Today , we will discuss about Delete Files based on Specified Character.  
 
private void deletefilescheckwithstartingword(string inputPath,char ch) 
 { 
string[] InputPath = System.IO.Directory.GetFiles(inputPath); 
foreach (string fileName in InputPath)
 {
 FileInfo fileInformation = new FileInfo(fileName);
 string file = fileInformation.Name; char[] letter = file.ToCharArray(); 
if (letter[0] == ch)
 {
 System.IO.File.Delete(fileName);
 }
 } 
 } 

Happy Coding! 

No comments:

Post a Comment