I've been trying to open an excel file in my ASP.NET MVC project (I use Syncfusion library for that). For some reason, when I publish the webapp with Visual Studio, I get the
"Access to the path 'D:\home\site\wwwroot' is denied."
error.
The file is correctly uploaded to the webserver (I can download it just fine when I input the path in the browser). I've looked into this question, but there is no WEBSITE_RUN_FROM_PACKAGE setting in my azure webapp. I went into Kudu, opened up the console and ran
icacls "D:\home\site\wwwroot"
which gave this output
D:\home\site\wwwroot Everyone:(I)(OI)(CI)(M,DC)
BUILTIN\Administrators:(I)(OI)(CI)(F)
So, with my little understanding of acls, it seems that Everyone has Modify permission to this folder.
Which means that I'm at a loss as to what to do.
Code:
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
application.EnablePartialTrustCode = true;
IWorkbook workbook = application.Workbooks.Create(1);
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
dir = dir.Replace("file:\\", "");
dir = dir.Replace("\\bin", "");
var dirXlsx = "\\Areas\\Stampe\\Content\\Excel\\RapportoProvaMare(version1).xlsx";
FileStream s = File.OpenRead(dir + dirXlsx);
IWorkbook source = excelEngine.Excel.Workbooks.Open(s);
I don't think the Syncfusion code has anything to do with the issue, I'm just reporting it for completeness.
Anybody have an idea as to what the issue could be?
EDIT: To be more specific, I'm publishing the code via Visual Studio, with the excel file in a folder of the website (just like you would do for an image). All the test I've made to the dir
variable have been tested on the Azure environment (we have a duplicate test environment). I just need to read the excel file from the local website folder and process it before sending it to the user.