title: Download files in API ASP.Net Core
body: <p>I'm trying to create an API that downloads a specific file from the server in ASP.Net Core.
  I'm Using the ASP.NET Boilerplate.
  I've tried every solution i found, and non of them helped me.
  most of the solutions I've tried, implements something like this:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Download(string filename)  
    {  
        if (filename == null)  
            return Content("filename not present");  
  
        var path = Path.Combine(  
                       Directory.GetCurrentDirectory(),  
                       "wwwroot", filename);  
  
        var memory = new MemoryStream();  
        using (var stream = new FileStream(path, FileMode.Open))  
        {  
            await stream.CopyToAsync(memory);  
        }  
        memory.Position = 0;  
        return File(memory, GetContentType(path), Path.GetFileName(path));  
    } 
  </code></pre>
  
  <p>And when using it, I always get an error on the last line <code>Non-invocable member 'File' cannot be used like a method</code>.</p>