1
I did several searches on the net to find a way to generate a spreadsheet and save to disk.
As it comes to web, this can only be done via download, and all the examples searched (at least by me), I fall in the Fileresult. Turns out it’s not working.
I took a simple example and gives the same error. See the code
public FileResult Download()
{
byte[] fileBytes = System.IO.File.ReadAllBytes(@"c:\folder\myfile.ext");
string fileName = "myfile.ext";
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
On that line I get the error
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
That is the mistake:
Non-invocable Member 'File' cannot be used like a method.
How do I fix this mistake?
Says that File does not exists in the Namespace System.Web.Mvc and if change to Fileresult gives the error of the original post
– pnet
Strange, according to the Microsoft documentation this exists: https://msdn.microsoft.com/en-us/library/system.web.mvc.controller.file(v=vs.118). aspx#M:System.Web.Mvc.Controller.File%28System.String,System.String,System.String%29
– João Martins
Reading the documentation now I understood that I could not use outside of a controller. Already fixed.
– pnet