Reputation: 7164
I'm working on a ASP.NET MVC 5 project. In this project I want user to download an Excel file using this code :
var workbook = new ExcelFile();
workbook.Save("Excel.xlsx");
But when I enter the URL to download the Excel file. I get the exception :
Access to the path 'C:\Program Files (x86)\IIS Express\Excel.xlsx' is denied.
How can I modify my code so that user can download the Excel file wherever he wants? Instead of IIS Express folder. Thanks.
Upvotes: 2
Views: 10752
Reputation: 528
I know its too late, but in order to access the folder you should run visual studio as admin.
Upvotes: 1
Reputation: 437
In my opinion you have two options.
1: Chage the permission of the IIS folder/directory.
2: Save the file to Response an let the user choose per SaveFileDialog(try this: Downloading Excel File)
Upvotes: 2