WCF – use a file in the App_Data folder

If your web service needs information from some external files, a logical place for these files is the App_Data folder.

To get the fysical path of the file in a WCF service you can use this code:

RolemappingPath = HostingEnvironment.MapPath(@”/App_Data/RoleMapping.xml”);

The class HostingEnvironment is in the namespace System.Web.Hosting, and you will also need to add a reference to System.Web.dll.

Reference: http://msdn.microsoft.com/en-us/library/system.web.hosting.hostingenvironment.mappath.aspx

Advertisement

About Gaston

MCT, MCSD, MCDBA, MCSE, MS Specialist
This entry was posted in Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s