views:

1011

answers:

1

How to access App_Data folder in WCF service?

I have placed a xslt file and I am not able to find the path.

+3  A: 

You need to use HostingEnvironment.ApplicationPhysicalPath:

string myXsltFilename = HostingEnvironment.ApplicationPhysicalPath +
  "App_Data\\my.xslt";
Steven Robbins
You should use the static methods on the Path class when working with paths.
casperOne
Possibly, but every MSDN article I've ever seen using this technique always uses a string literal for App_Data.
Steven Robbins
HostingEnvironment.MapPath() combines the two. There is no constant for App_Data however so you are stuck with hard coding that. Not that it can change though.
Maurice