connectseekers.com

Wednesday, 15 October 2014

Validate Directory Exist or Not in C#.Net In Windows Application

10/15/2014 - By Pranav Singh 0

This article will show you how you can validate or check whether directory in a path exists or not using c#.net in windows application.


So for this article first we will create a new windows application and add a textbox and a button control. After adding all controls your form will looks as shown below.


Now add the below code on button click of the form.

using System;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApplication9
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //Validate Directory Exist or Not in C#.Net In Windows Application
        private void button1_Click(object sender, EventArgs e)
        {
            if (Directory.Exists(txtPath.Text))
            {
                MessageBox.Show("Directory already exists.");
            }
            else
            {
                MessageBox.Show("Directory DOES NOT exists.");
            }
        }
    }
}

Now run the application to check the output. We will validate a demo folder at a given path.


Now add the path and click on validate.





Now click on button. You will get the directory already exist message. Now add a change the directory name and click on validate.



About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top