Question

I am trying to read a file during Application_Start from my web application.

However at the Application_Start I am unable to get the file published to the Web Directory.

protected void Application_Start(object sender, EventArgs e)
{
    using (StreamReader reader = File.OpenText("settings.json"))
    {

    }
}

The file was added to the web project, and set to Copy to Output Folder.

Was it helpful?

Solution

http://msdn.microsoft.com/en-us/library/system.web.httpserverutility.mappath(v=vs.110).aspx

Using the MapPath method returns the actual file-system path to the root of your site.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top