How to access a file in the bin directory of my WCF service?

0

I have a service which is responsible for sending emails with a template html as a base, which I try to read as shown below, so far I can not read it. My service is hosted on IIS 7.5

What I am trying to do is the following:

string path = System.Web.Hosting.HostingEnvironment.MapPath("~/bin/Template/file.html");

text = File.ReadAllText(@path);

But path remains as null

How could I access that html file?

In another attempt I tried to use the following but with the same result:
path = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
    
asked by Alan 15.09.2016 в 00:34
source

1 answer

1

to retrieve the folder where your service is running you should use Reflection in this way

string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
    
answered by 15.09.2016 / 14:13
source