1
Reply

create directory in asp.net mvc

kainat younas

kainat younas

Jul 12 2017 8:19 AM
291
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
 

Answers (1)