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