51 lines
1.6 KiB
C#
51 lines
1.6 KiB
C#
using Gather.Common.Util;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace GatherAPI.Controllers.back
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class DeleteFileController : Controller
|
|
{
|
|
private readonly IWebHostEnvironment _webHostEnvironment;
|
|
|
|
public DeleteFileController(IWebHostEnvironment webHostEnvironment)
|
|
{
|
|
_webHostEnvironment = webHostEnvironment;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除文件接口
|
|
/// </summary>
|
|
/// <param name="Path">文件路径</param>
|
|
/// <returns></returns>
|
|
[Authorize]
|
|
[HttpGet]
|
|
public JsonResult Index(string Path)
|
|
{
|
|
try
|
|
{
|
|
//var webRootPath = _webHostEnvironment.WebRootPath;
|
|
//if (System.IO.File.Exists(webRootPath + "/" + Path))
|
|
//{
|
|
// var array = Path.Split('/');
|
|
// if (array.Length > 0)
|
|
// {
|
|
// Array.Resize(ref array, array.Length - 1);
|
|
// }
|
|
// var new_path = string.Join("/", array);
|
|
// Tool.DeleteDir(webRootPath + new_path);
|
|
//}
|
|
return Json(Tool.GetJsonWithCode(APICode.Success, "删除成功"));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Util.LogHelper.WriteLog(ex.Message + ",行号:" + ex.StackTrace);
|
|
return Json(Tool.GetJsonWithCode(APICode.Fail, "发生错误,请联系管理员。"));
|
|
}
|
|
}
|
|
}
|
|
}
|