简体   繁体   中英

How do I get the Web Directory during Application_Start?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM