Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net Web API cant read file from file path [duplicate]

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

I tried this

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

and also this

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

however none of them is working i couldnt read the data file , how can i read it ?

Thanks

like image 383
Kaan Baris Bayrak Avatar asked Jul 09 '15 00:07

Kaan Baris Bayrak


1 Answers

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

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

Oh, and a friendly ask: please search StackOverflow before posting questions - this has been asked and answered here

like image 177
Rich Turner Avatar answered Oct 05 '22 17:10

Rich Turner