qwj
2023-08-16 4c4ae7711f7886810735ce7152ec62baf523ddb3
增加删除文件接口
1个文件已修改
39 ■■■■■ 已修改文件
DocumentFile.Service/Controllers/DocumentController.cs 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
DocumentFile.Service/Controllers/DocumentController.cs
@@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;
namespace DocumentFile.Service.Controllers
{
@@ -82,6 +80,41 @@
        }
        /// <summary>
        /// 删除文件
        /// </summary>
        /// <param name="delurl"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult DeleteFile([FromForm] string[] delurl)
        {
            ReturnMsg msg = new ReturnMsg();
            try
            {
                if(delurl!=null && delurl.Length > 0)
                {
                    var dir = AppDomain.CurrentDomain.BaseDirectory;
                    foreach (var item in delurl)
                    {
                        if (!string.IsNullOrEmpty(item))
                        {
                            var path = dir + item;
                            if (System.IO.File.Exists(path))
                            {
                                System.IO.File.Delete(path);
                            }
                        }
                    }
                    msg.code = 1;
                }
            }
            catch (Exception ex)
            {
                NLogProvider.GetInstance().Error(ex);
            }
            return new JsonResult(msg);
        }
        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="url"></param>