i want to create directory for save image.. my code is that
[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
if (file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
var path = Path.Combine(Server.MapPath("~/Assets/Upload/Users/Profiles"), fileName);
file.SaveAs(path);
}
return RedirectToAction("Index");
}
when i use this line with else statement it is not work
else
{
Directory.CreateDirectory(Server.MapPath("~/Assets/Upload/Users/Profiles"));
}
iwant to know how i can set my code please help me