BootstrapAdmin/Bootstrap.Admin/Models/ProfilesModel.cs

40 lines
1.1 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Hosting;
2018-06-07 00:45:47 +08:00
using Microsoft.AspNetCore.Mvc;
using System.IO;
2016-12-10 12:23:59 +08:00
namespace Bootstrap.Admin.Models
{
/// <summary>
///
/// </summary>
public class ProfilesModel : ThemeModel
2016-12-10 12:23:59 +08:00
{
/// <summary>
/// 获得 头像文件大小
2016-12-10 12:23:59 +08:00
/// </summary>
public long Size { get; }
/// <summary>
/// 获得 头像文件名称
2016-12-10 12:23:59 +08:00
/// </summary>
public string FileName { get; }
/// <summary>
///
/// </summary>
/// <param name="host"></param>
2018-06-07 00:45:47 +08:00
/// <param name="controller"></param>
public ProfilesModel(ControllerBase controller, IHostingEnvironment host) : base(controller)
2016-12-10 12:23:59 +08:00
{
if (host != null)
2016-12-10 12:23:59 +08:00
{
var fileName = Path.Combine(host.WebRootPath, Icon.TrimStart('~', '/').Replace('/', Path.DirectorySeparatorChar));
if (File.Exists(fileName))
{
Size = new FileInfo(fileName).Length;
FileName = Path.GetFileName(fileName);
}
2016-12-10 12:23:59 +08:00
}
}
}
}