Validate File Name Number or String in C#.net

Naraayanan
Posted by Naraayanan under C# category on | Points: 40 | Views : 20451
  private void   createfirstFile(string inputPath)
{
#region Check Directory Exists
if (Directory.Exists(inputPath))
{
cntstringName = 0;
string[] files = Directory.GetFiles(inputPath);
foreach (string file in files)
{
string name = Path.GetFileName(file);
string[] str = name.Split('.');

foreach (char ch in str[0])
{
bool chkAlphaNum = Char.IsLetter(ch);
if (chkAlphaNum)
{
chk = true;
}
else
{
chk = false;
}

}
cntstringName = cntstringName + 1;
}
if (chk)
{
MessageBox.Show("No of string File Names:" + " " + cntstringName);
}
else
{
MessageBox.Show("No of Numberic File Names:" + " " + cntstringName);
}
}
else
{
MessageBox.Show("Please create a Directory and files ");
}



  createfirstFile("Folder Path);

Comments or Responses

Posted by: Kulprachi84 on: 3/15/2012 Level:Starter | Status: [Member] | Points: 10
Good

Login to post response