Hello guys i am trying to create a folder using c# mvc3. I have the following code in my controller
string path = Path.Combine("~/Content/albums", album.title.Replace(" ", ""));
Directory.CreateDirectory(path);
but it does not seem to create a folder. I have tried using directory without relative paths and it works
Directory.CreateDirectory("c:/test");
Thank you
Try the Server.MapPath (if in the Controller) or System.Web.Hosting.HostingEnvironment.MapPath (if outside the Controller) first on the Content, it maps the virtual resource path to the physical path,
so:
And then create the directory.