Link to home
Create AccountLog in
Avatar of curiouswebster
curiouswebsterFlag for United States of America

asked on

What does Request.MapPath() do and how does it work?

I want to access a file that's in a folder for the default Physical Path.  So the following code works:

             String outPutPath = Path.GetDirectoryName(Request.PhysicalPath) + "\\output";
             StreamWriter w = File.AppendText(outPutPath + "\\xmleventsincall.txt");

Is there a nicer way of doing this using MapPath()?

Thanks,
newbieweb
ASKER CERTIFIED SOLUTION
Avatar of Mohit Vijay
Mohit Vijay
Flag of India image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
above not worked?
Avatar of curiouswebster

ASKER

Yes, but what is keeping track of the location of "Hello.aspx"?  And what if there are two copies of that file in different directories?
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
so does that mean IIS does not allow you to have the same file in two subfolders?
In your example, Hello.aspx is located in three folders.  I don't see how it can tell you the path in that case.
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Thanks.