?
Solved

WEB site root folder.

Posted on 2014-01-30
4
Medium Priority
?
570 Views
Last Modified: 2014-01-30
I want the root folder of my WEB site.

Can anyone tell me what the difference is between these two:

System.AppDomain.CurrentDomain.BaseDirectory()

verses

Me.Page.Request.PhysicalApplicationPath
0
Comment
Question by:HLRosenberger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 15

Assisted Solution

by:Ess Kay
Ess Kay earned 1000 total points
ID: 39822407
If you want to find files in the same directory as your application, AppDomain.CurrentDomain.BaseDirectory is the correct choice.

Environment.CurrentDirectory is a value that can and will change throught the course of running your application. For instance, using default parameters, the OpenFileDialog in WinForms will change this value to the directory where the file was selected from.



Me.Page.Request.PhysicalApplicationPath is for a specific page. if you change pages within a domain, this will change, but the domain link will stay the same



The difference is different scopes
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 39822430
Sounds like I want:

System.AppDomain.CurrentDomain.BaseDirectory()

Regardless of the page, or current directory, this will give me the root folder of my WEB site, correct?
0
 
LVL 8

Accepted Solution

by:
Pramod Bugudai earned 1000 total points
ID: 39823197
Correct!

System.AppDomain.CurrentDomain.BaseDirectory() - Gets the base directory that the assembly resolver uses to probe for assemblies.Per MSDN, an App Domain "Represents an application domain, which is an isolated environment where applications execute." When you think about an ASP.Net application the root where the app resides is not the bin folder. It is totally possible, and in some cases reasonable, to have no files in your bin folder, and possibly no bin folder at all. Since AppDomain.CurrentDomain refers to the same object regardless of whether you call the code from code behind or from a dll in the bin folder you will end up with the root path to the web site.


.Page.Request.PhysicalApplicationPath - Returns local file system path of the virtual root for the app.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 39823204
thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question