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

Top 5 Contributors of the Month

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

 Subscribe to Code Snippets

Check Particulare file Format are in the Folder using C#.Net

Posted By:Narayanan       Posted Date: February 26, 2012    Points: 40    Category: File Operation    URL: http://www.dotnetspark.com  

The following code returns Check Particular file format files in the Folder using C#.net

Declaration Part:
public static int chknofiles;
Function Part:
    public static bool chkfileextention(string filepath, string fileextension)

            string[] fsDir = Directory.GetFiles(filepath);
            foreach (string f in fsDir)
                string fName = f.Substring(filepath.Length + 1);
                string[] fileExt = fName.Split('.');
                if (fileExt[1] == fileextension)
                    chknofiles = chknofiles + 1;
            if (chknofiles > 1)
                chkfileextension = true;
                chkfileextension = false;
            return chkfileextension;

Coding Part:
  bool chk = chkfileextention(txtBrowsFile.Text, "pcl");
            if (chk)



Further Readings:


No response found. Be the first to respond this post

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