I got a requirement that to create folders and sub-folders in c# which works fine in Local machine. But when I publish that code and pasted in IIS 7 wwwroot, the folders are not creating. I should create as many folders as per requirements in the folder of IIS7 wwwroot. Here is my code which works fine in creating folders in Local Machine.
string root = Server.MapPath("~");
string path = Path.GetDirectoryName(root);
string brandname = addbrand.Text;
bool isExists = System.IO.Directory.Exists(Server.MapPath(@"~/"+path+"/"+brandname));
if (!isExists)
System.IO.Directory.CreateDirectory(Server.MapPath(@"~/" + path + "/" + brandname));
if (uploadimg.HasFile)
{
string FileName = Path.GetFileName(uploadimg.PostedFile.FileName);
uploadimg.SaveAs(@root+"/Images/" + FileName);
}
Did I miss anything ? Also I gave permissions for write in Security menu too .