Create Folder Using C# | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

Create Folder Using C#

Friday

Create Folder Using C#:

          By using the following code you can give the user the ability to enter a directory name, check to see if it already exists and if not then create the folder and upload the files there.

First create a text box name as "txtFolderName" and a submit button name as "Create Folder" . It's just look like...






Next, the bellow c# code used to validate if folder name exists and create a folder with name of "Image"

protected void btnCreateFolder_Click(object sender, EventArgs e)
    {
 
          if (!System.IO.Directory.Exists(MapPath(MyTree.SelectedValue + "\\" + txtFolderName.Text)))
          {           
            System.IO.Directory.CreateDirectory(MapPath(txtFolderName.Text));
            lblError.Text = "Created Successfully";
            txtFolderName.Text = "";     
          }             else
            {
                
lblError.Text = "Folder Already Exist";
            }
 

    }

Now you can see your new folder for your specified path and then leave some comment to encourage us.

0 comments:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets