public string Save(int id, HttpPostedFileBase image, FileLocations location) { var path = string.Empty; try { var extension = Path.GetExtension(image.FileName); var folderPath = this.server.MapPath($"~/Content/DynamicResources/{location.ToString()}"); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } path = $"~/Content/DynamicResources/{location.ToString()}/{id}{extension}"; var serverPath = server.MapPath(path); image.SaveAs(serverPath); } catch { return(string.Empty); } return(path); }