net core 3.1 open file

2021-03-03 17:30

阅读:302

标签:action   ppi   abc   col   class   tty   empty   bsp   rem   

[HttpGet]
        public IActionResult GetFile(string filepath)
        {
            if (string.IsNullOrEmpty(filepath)) filepath = "D:\\ABC.log";
            var provider = new FileExtensionContentTypeProvider();
            FileInfo fileInfo = new FileInfo(filepath);
            var ext = fileInfo.Extension;
            new FileExtensionContentTypeProvider().Mappings.TryGetValue(ext,out var contenttype);
            return File(System.IO.File.ReadAllBytes(filepath), contenttype ?? "application/octet-stream", fileInfo.Name);
        }

 

net core 3.1 open file

标签:action   ppi   abc   col   class   tty   empty   bsp   rem   

原文地址:https://www.cnblogs.com/LiuFengH/p/13275019.html


评论


亲,登录后才可以留言!