diff --git a/24Hour/Controllers/Common/CommonController.cs b/24Hour/Controllers/Common/CommonController.cs index 16095d7..aa24af0 100644 --- a/24Hour/Controllers/Common/CommonController.cs +++ b/24Hour/Controllers/Common/CommonController.cs @@ -2764,12 +2764,15 @@ namespace _24Hour.Controllers.Common } var FileName = System.IO.Path.GetFileName(filename); var FilePath = filename; + return new FileStreamResult(new FileStream(FilePath, FileMode.Open), "application/octet-stream") { FileDownloadName = FileName }; + } else { return BadRequest(); } + } /// @@ -2781,11 +2784,10 @@ namespace _24Hour.Controllers.Common [Route("RequestDeleteFile")] public Result RequestDeleteFile(string filename) //[FromBody] dynamic Json { - if (System.IO.File.Exists(filename)) { filename = filename.Replace(@"\\", @"\"); - var data = System.IO.Path.Combine(Environment.CurrentDirectory, "wwwroot","temp"); + var data = System.IO.Path.Combine(Environment.CurrentDirectory, "wwwroot", "temp"); if (filename.Contains(data) == false) { return Result.Error("操作失败" + "不可删除"); @@ -2796,9 +2798,9 @@ namespace _24Hour.Controllers.Common { System.IO.File.Delete(filename); } - catch(Exception ex) + catch (Exception ex) { - return Result.Error("操作失败"+ex.Message); + return Result.Error("操作失败" + ex.Message); } return Result.Success("操作成功"); @@ -2919,7 +2921,7 @@ namespace _24Hour.Controllers.Common { var urlpath = s.Split('/'); - var path = Path.Combine(Environment.CurrentDirectory, "wwwroot" , Path.Combine(urlpath)); + var path = Path.Combine(Environment.CurrentDirectory, "wwwroot", Path.Combine(urlpath)); if (System.IO.File.Exists(path)) { return Elight.Utility.Encrypt.DataEncryption.Decryptiones(path);