You are on page 1of 1

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("Abhimanyu Kumar Vatsa"); //New Directory Name in string variable CreateDirectoryIfNotExists(NewDirectory); //Calling the function to create new directory } }

You might also like