I'm trying to create a folder using the two methods below.
Method 1
if (directoryInfo.Exists)
{
directoryInfo.CreateSubdirectory(ddlCat.SelectedItem.Text);
Label1.Text = "Directory " + ddlCat.SelectedItem.Text + " Created";
}
Method 2
var folder = Server.MapPath("~/UploadImages/" + ddlCat.SelectedItem.Text);
if (!Directory.Exists(folder))
{
DirectoryInfo di = Directory.CreateDirectory(folder);
}
Where ddlCat is a dropdownlist.
before executing the code, I modified the permission of the folder to Full for the current user. However, I'm still getting this error:
UnauthorisedAccessException was unhandled by the user code Access to the path 'Accessories' is denied.
The folder in which I'm creating subfolder is "c:\inetpub\wwwroot\xyz\UploadImages"
Can someone please guide me?