Solved

WEB site root folder.

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need to Interpret Json in Vb.net ( .net 3.5  framework) 11 52
aspx ascx, c# 7 45
Updating Printer Details in VB.Net 16 43
SQL query joining 6 tables in asp.net 4 33
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

710 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