Equivalent AppDomain.CurrentDomain.BaseDirectory

G

Guest

Hi,

What's the equivalent for AppDomain.CurrentDomain.BaseDirectory in asp.net?
Trying to access web app directory for reading and writing xml files.

Thanks,

JJ
 
W

William F. Robertson, Jr.

Have you looked at Server.MapPath?

string s = Server.MapPath( "default.aspx" );

s, on my machine, is "C:\inetpub\wwwroot\tempasp\default.aspx"

bill
 
K

Ken Cox [Microsoft MVP]

Hi JJ,

If you're looking for the path of the Web app's directory, you could get it
like this:

Label1.Text = Server.MapPath("")

Is that what you meant?

Ken

'
 
K

Kevin Spencer

string AppDirectory = Server.MapPath("\");

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
G

Guest

Ok Im running this on my Dev machine which gives me a false path. I am
debugging so what happens is when I use Server.MapPath it shows me
"C:\localhost\websitename\ " which really isn't where the files are for
project.
So how can I get this to work so I can debug on dev machine?

Thanks,

JJ
 
W

William F. Robertson, Jr.

Try using Request.PhysicalApplicationPath.

That should return the root directory of your application.

bill
 
J

Juan T. Llibre

That will do it, allright.
So will Request.ServerVariables("APPL_PHYSICAL_PATH")



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top