.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani

Home >> Code Snippets >> File Operation >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Validate File Name in Numer Or String in C#.net

Posted By:Narayanan       Posted Date: March 13, 2012    Points: 25    Category: File Operation    URL: http://www.dotnetspark.com  

Here , I will give a Validate file Name is Numeric or string in C#.net
 

   
      #region 
        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 ");
            }
            #endregion   Check Directory Exists 
        }
        #endregion
  createfirstFile(FolderPath);


     

Further Readings:

Responses
Author: Pawan Awasthi         Company URL: http://www.dotnetspark.com
Posted Date: March 23, 2012

Hai Narayan,
its good article to learn the file names as the numeric and strings...good code work in C#.

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend