using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.FileProviders.Physical; using Microsoft.Extensions.Options; using System.IO; namespace IRaCIS.Core.API { //public class MultiDiskStaticFilesMiddleware //{ // public MultiDiskStaticFilesMiddleware(RequestDelegate next,IWebHostEnvironment webHostEnvironment, StaticFileOptions options) // : base(next, webHostEnvironment, options) // { // } // public override async Task InvokeAsync(HttpContext context) // { // try // { // await base.InvokeAsync(context); // } // catch (FileNotFoundException) // { // var disks = GetDisks(); // foreach (var disk in disks) // { // var fileInfo = new PhysicalFileInfo(new FileInfo(Path.Combine(disk, Options.RequestPath.Value))); // if (fileInfo.Exists) // { // await SendFileAsync(context, fileInfo); // return; // } // } // await Next.Invoke(context); // } // } // private string[] GetDisks() // { // // 获取系统中所有可用的磁盘 // return DriveInfo.GetDrives() // .Where(d => d.IsReady && d.DriveType == DriveType.Fixed) // .Select(d => d.RootDirectory.FullName) // .ToArray(); // } //} }