Path.Combine()
https://blog.csdn.net/liyazhen2011/article/details/88680388 --参考
        private readonly IWebHostEnvironment _env;
        public FileService( IWebHostEnvironment env)
        {
            _env = env;
        }
 //如果path2 以 \ 或 / 开头,则返回 path2。
            var fileAddress = Path.Combine(_env.WebRootPath, file.FileUrl);
            if (!File.Exists(fileAddress))
            {
                throw new ArgumentNullException("文件不存在");
            }
return await File.ReadAllBytesAsync(fileAddress); // Task<byte[]>
pubilc async Task<FileContentResult> getfile(){
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet);
}
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号