How to dispose file stream in api ?
Let assume that I need to call this api 10 times.
[HttpGet("{fileName}")]
public async Task<IActionResult> Get(string fileName)
{
var res = File.Open(path, FileMode.Open);
var file = File(res, "application/zip", fileName);
return file;
}
I can't dispose stream before is returned from api method.
When I call it second time I will get exception:
The process cannot access the file 'C:\test\example.zip' because it is being used by another process.