What is the universal MapPath equivalent to the below? Universal, meaning, that I could use it in both client-side and server-side .NET apps, not just in server-side apps.
System.Web.Hosting.HostingEnvironment.MapPath(virtualPath)
The reason I'm asking is I want to reuse the same piece of code in MVC.NET server-side apps, but as well in .NET standalone apps running on the clien开发者_Python百科t machine. Therefore I want to have a universal function to map my virtual paths to within my App's root folder.
There is no universal method for that, because there is no exact equivalent of the web root in a desktop application.
You could roll your own method that does different things depending on whether a web context exists or not, but then you would have to reference the System.Web
dll in all your desktop applications also, which would certainly contradict any gain you are trying to make by reusing some of your code.
精彩评论