Connect with me
Search
Twitter Feed
Navigation
« One of the only rare instances where VB.NET > C# | Main | Cross Browser Copy and Paste - with ZeroClipboard *updated* »
Friday
Apr092010

Getting the physical folder path of a virtual path or directory in WCF

I had a request from a client today to save something uploaded through WCF to the local disk to a particular sub folder.

Normally this is easy in ASP.NET with Server.MapPath but this isn’t available in the WCF application.

You can get the path of the application hosting the WCF service using:

var physicalPath = AppDomain.CurrentDomain.BaseDirectory

To get a virtual path you can use:

VirtualPathExtension extension = OperationContext.Current.Host.Extensions.Find<VirtualPathExtension>();
var virtualPath = extension.VirtualPath;

References (1)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
    Response: All about server
    [...]Getting the physical folder path of a virtual path or directory in WCF - Blog - EricPhan.info[...]

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>