using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using System.IO;
namespace Bootstrap.Admin.Models
{
///
///
///
public class ProfilesModel : ThemeModel
{
///
/// 获得/设置 头像文件大小
///
public long Size { get; }
///
///
///
public string FileName { get; }
///
///
///
///
public ProfilesModel(ControllerBase controller) : base(controller)
{
var host = controller.HttpContext.RequestServices.GetService(typeof(IHostingEnvironment)) as IHostingEnvironment;
if (host != null)
{
var fileName = Path.Combine(host.WebRootPath, Icon.TrimStart('~', '/').Replace('/', '\\'));
if (File.Exists(fileName))
{
Size = new FileInfo(fileName).Length;
FileName = Path.GetFileName(fileName);
}
}
}
}
}