Solved

WEB site root folder.

Posted on 2014-01-30
4
534 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now