Create Folder Using C#:

Posted by Prince | 7:55:00 PM | | 0 comments »

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

Related Posts Plugin for WordPress, Blogger...