ASP.NET - how to solve this problem??in asp.net

Asked By mani on 27-Jan-12 05:50 AM
hi..i have file upload controll in have only one folder called main..
i need to create subfolder dynamically  and store image in to that folder...any help??
kalpana aparnathi replied to mani on 27-Jan-12 06:02 AM
hi,

string FolderName =Path.COmbine(Server.MapPAth("~/Images"),"1"))
 
if(!System.IO.Directory.Exists(FolderName))
 
System.IO.Directory.CreateDirectory(FolderName)

dipa ahuja replied to mani on 27-Jan-12 07:45 AM
void CreateDir()
{
  string pathToCreate = "~/myDir1";
  if (Directory.Exists(Server.MapPath(pathToCreate)))
  {
    //In here, start looping and modify the path to create to add a number
    //until you get the value needed
  }
 
  //Now you know it is ok, create it
  Directory.CreateDirectory(Server.MapPath(pathToCreate));
}