Equivalent AppDomain.CurrentDomain.BaseDirectory

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
Have you looked at Server.MapPath?

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

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

bill
 
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

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

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
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
 
Try using Request.PhysicalApplicationPath.

That should return the root directory of your application.

bill
 
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...
======================
 
Back
Top