Server.MapPath

  • Thread starter Thread starter Peter Kirk
  • Start date Start date
P

Peter Kirk

Hi

we have some classes which sometimes run in a web application, and sometimes
run in standalone applications. These classes have some configuration
parameters, of which one is a file-path to some resources (eg. to some text
files).

In order to ease configuration when deployed in a web-app (especially if
redeployed or if the server is altered) we use
HttpContext.Current.Server.MapPath(...)

but this means that the classes no longer run in a non web-application. What
is a good way around this? Should be check if there is a HttpContext, and if
so then "map" the path?


Thanks,
Peter
 
You can get the path the exe/dlls are in with
System.AppDomain.CurrentDomain.SetupInformation.PrivateBinPath

HTH


Ciaran O'Donnell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top