Solved

WEB site root folder.

Posted on 2014-01-30
4
559 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 250 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 250 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

624 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