0

I'm in the midst of refactoring some 'inherited' business logic code that for the ASP.NET side needs to be initialized with an absolute path, but on the WinForms / WPF side only with a relative path to a GetExecutingAssembly directory.

I want to merge these two into a relative setting stored in Web.config or App.config so I can do xcopy deployment of both without having to hard-code path names.

Which ways are there to find the location of an assembly and the relative files deployed with it, without it having to depend on the ASP.NET specific Server.MapPath or HostingEnvironment.MapPath?

Community
  • 1
  • 1
Jeroen Wiert Pluimers
  • 23,965
  • 9
  • 74
  • 154

1 Answers1

1

You could use a path relative to AppDomain.CurrentDomain.BaseDirectory.

This will be the directory containing the executable for a client app, and the web site root directory for ASP.NET.

Joe
  • 122,218
  • 32
  • 205
  • 338