Wednesday, November 21, 2012

Investigations: How to identify current path in referenced library in MVC application?

Following is the exact scenario in my application:

1) MVC application is referencing one DLL (a Class library project).
2) some code in the class library need to access folders and files from the MVC application.
Say, there is one folder named as "Templates" in root of my MVC application.
How should I able to get the path of that folder in context of execution path from any method of the class library.
If I try "~\templates" or "\templates", it looks for folder in C:\Program Files\... instead of the websites folder.
If I try "templates", it looks for folder in C:\ only.
any idea of how to achieve this

1 comment:

  1. Resolved by a reply on ASP.NET Forum

    - System.Web.DLL reference in the class library project.
    - Yes, then its just HttpContext.Current.Server.MapPath..


Thanks for visiting my blog.
However, if this helped you in any way, please take a moment to write a comment.