Solved

WEB site root folder.

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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