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

Top 5 Contributors of the Month
Sandeep Singh

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

 Subscribe to Code Snippets

How can we get this path is Folder or Not?

Posted By:Narayanan       Posted Date: September 25, 2011    Points: 40    Category: File Operation    URL: http://www.dotnetspark.com  

In this code sample ,i explain to check whether a given path is Folder or not?

private void button1_Click(object sender, EventArgs e)
           string filepath = @"D:\Easy";
            if (IsCheckFolder(filepath))
                MessageBox.Show("The given path is a Folder");

                MessageBox.Show("The given path is not a Folder");
// Function for Check folder or not 
        public bool IsCheckFolder(string path)
            return ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory);


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