Wednesday 15 February 2012

Create Folder In ASP.Net Run Time

 Create Directory In ASP.Net Run Time
Sometime you have to keep your files or client files in particular folder
which would be create on run time



     private void CreateDirectoryIfNotExists(string NewDirectory)
    {
        try
        {
            // Checking the existance of directory
            if (!Directory.Exists(NewDirectory))
            {
                //If No any such directory then creates the new one
                Directory.CreateDirectory(NewDirectory);
                Label1.Text = "Directory Created";
            }
            else
            {
                Label1.Text = "Directory Exist";
            }
        }
        catch (IOException _err)
        {
            Response.Write(_err.Message);
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string NewDirectory = Server.MapPath("Vijay Negi");
        //New Directory Name in string variable
        CreateDirectoryIfNotExists(NewDirectory);
        //Calling the function to create new directory
    }

No comments:

Post a Comment

Print Only Grid View in ASP.net

ASP.net How to Print Only GridView < div id ="gridviewDiv" >   < asp:GridView ID ="gridViewToPri...