diff --git a/Bootstrap.Admin/Controllers/AdminController.cs b/Bootstrap.Admin/Controllers/AdminController.cs
index 3d864ccd..9204f65b 100644
--- a/Bootstrap.Admin/Controllers/AdminController.cs
+++ b/Bootstrap.Admin/Controllers/AdminController.cs
@@ -1,5 +1,6 @@
using Bootstrap.Admin.Models;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System;
@@ -87,8 +88,9 @@ namespace Bootstrap.Admin.Controllers
///
///
///
+ ///
///
- public ActionResult Profiles() => View(new ProfilesModel(this));
+ public ActionResult Profiles([FromServices]IHostingEnvironment host) => View(new ProfilesModel(this, host));
///
///
diff --git a/Bootstrap.Admin/Controllers/Api/ProfilesController.cs b/Bootstrap.Admin/Controllers/Api/ProfilesController.cs
index dc83e54e..219ed3b5 100644
--- a/Bootstrap.Admin/Controllers/Api/ProfilesController.cs
+++ b/Bootstrap.Admin/Controllers/Api/ProfilesController.cs
@@ -36,7 +36,7 @@ namespace Bootstrap.Admin.Controllers.Api
var webSiteUrl = DictHelper.RetrieveIconFolderPath();
fileName = string.Format("{0}{1}", userName, Path.GetExtension(uploadFile.FileName));
var fileUrl = string.Format("{0}{1}", webSiteUrl, fileName);
- var filePath = Path.Combine(env.WebRootPath, webSiteUrl.Replace("~", string.Empty).Replace("/", "\\").TrimStart('\\') + fileName);
+ var filePath = Path.Combine(env.WebRootPath, webSiteUrl.Replace("~", string.Empty).Replace('/', Path.DirectorySeparatorChar).TrimStart(Path.DirectorySeparatorChar) + fileName);
var fileFolder = Path.GetDirectoryName(filePath);
fileSize = uploadFile.Length;
if (!Directory.Exists(fileFolder)) Directory.CreateDirectory(fileFolder);
@@ -53,7 +53,7 @@ namespace Bootstrap.Admin.Controllers.Api
fileName = files["key"];
if (!fileName.Equals("default.jpg"))
{
- fileName = Path.Combine(env.WebRootPath, $"images\\uploader\\{fileName}");
+ fileName = Path.Combine(env.WebRootPath, $"images{Path.DirectorySeparatorChar}uploader{Path.DirectorySeparatorChar}{fileName}");
try
{
if (System.IO.File.Exists(fileName)) System.IO.File.Delete(fileName);
diff --git a/Bootstrap.Admin/Models/ProfilesModel.cs b/Bootstrap.Admin/Models/ProfilesModel.cs
index 488273cb..32951ea7 100644
--- a/Bootstrap.Admin/Models/ProfilesModel.cs
+++ b/Bootstrap.Admin/Models/ProfilesModel.cs
@@ -22,13 +22,13 @@ namespace Bootstrap.Admin.Models
///
///
///
+ ///
///
- public ProfilesModel(ControllerBase controller) : base(controller)
+ public ProfilesModel(ControllerBase controller, IHostingEnvironment host) : base(controller)
{
- var host = controller.HttpContext.RequestServices.GetService(typeof(IHostingEnvironment)) as IHostingEnvironment;
if (host != null)
{
- var fileName = Path.Combine(host.WebRootPath, Icon.TrimStart('~', '/').Replace('/', '\\'));
+ var fileName = Path.Combine(host.WebRootPath, Icon.TrimStart('~', '/').Replace('/', Path.DirectorySeparatorChar));
if (File.Exists(fileName))
{
Size = new FileInfo(fileName).Length;