How to get file from path for minimal API

When working on minimal api, we can’t use the Image.FromFile() in minimal API. It doesn’t work because it has been remove. But there is another way.

You can use Results.File to return file to download from your Minimal APIs handler:

var mimeType = "image/png";
FileInfo f = new FileInfo("myImage.png");
var results = Results.File(f.FullName, contentType: mimeType);

The FileInfo is only to make sure we get the correct working path