0

I have a file called template.html in my project, set to Copy Always. When I run the api locally, from Visual Studio and do File.ReadAllText("template.html") I get Could not find file 'C:\Program Files (x86)\IIS Express\template.html'. Obviously, I could add an absolute path here, but that's not exactly portable. How can I access my file with a relative path?

Edit: my code is here. LocalPefChartinator is the main logic + CLI, Test is tests and WebInterface is the webapi bits.

DariusL
  • 4,007
  • 5
  • 32
  • 44

1 Answers1

0

Post linked by @MatíasFidemraizer helped.

HostingEnvironment.MapPath("~/template.html")

gives me an absolute path directly to my source if I run from Visual Studio. No idea what happens when I run it on AppHarbor, but it works.

DariusL
  • 4,007
  • 5
  • 32
  • 44