修改BUG:ExceptionController Post方法,对Error目录进行列举前未判断目录是否存在

This commit is contained in:
Argo-MacBookPro 2018-09-10 18:43:16 +08:00
parent b5cc93338a
commit fa80df6049
1 changed files with 2 additions and 3 deletions

View File

@ -1,9 +1,7 @@
using Bootstrap.Admin.Query;
using Bootstrap.DataAccess;
using Longbow.Web.Mvc;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.IO;
@ -36,8 +34,9 @@ namespace Bootstrap.Admin.Controllers.Api
public IEnumerable<string> Post()
{
var filePath = Path.Combine(AppContext.BaseDirectory, "Error");
if (!Directory.Exists(filePath)) return new List<string>();
return Directory.GetFiles(filePath)
.Where(f => Path.GetExtension(f).Equals(".log", System.StringComparison.OrdinalIgnoreCase))
.Where(f => Path.GetExtension(f).Equals(".log", StringComparison.OrdinalIgnoreCase))
.Select(f => Path.GetFileNameWithoutExtension(f)).OrderByDescending(s => s);
}
/// <summary>