Asp.net Web API cannot read file from file path

I am developing azure asp.net web api 2 and in my api I am trying to read a dataset, however I could not get my dataset.csv path. I connect to the ftp server and I found the route: .... / site / wwwroot / dataset.csv this,

I tried this

string path = "/site/wwwroot/dataset.csv";

as well as this

string path=Path.Combine(System.Web.HttpRuntime.AppDomainAppPath, "dataset.csv");

however, none of them work, I could not read the data file, how can I read it?

thank

+4
source share
1 answer

Try using instead System.Web.HttpContext.Current.Request.MapPath():

string path=System.Web.HttpContext.Current.Request.MapPath("~\\dataset.csv");

Oh, and a friendly question: please find StackOverflow before submitting questions - this has been asked and answered here

+11
source

All Articles