ASP.NET ServerMappath

I have the name A and inside A, I have 2 folders B and C, B has a child folder named child B, now I have a program in C.from C I need to get the physical path of childB When I give Server.MapPath ( "../B/childB/") It shows .Error.Can somebody tell me how to solve this?

0


source to share


3 answers


For security reasons MapPath

will not resolve paths outside the current application.



+2


source


Since you know the actual structure, why not get the current path to childB and just use Path.Combine for the rest?
Is there an actual reason why you want this to be one go using relative paths?
Another point - folder B cannot be defined in IIS and therefore relativity may not work ...



0


source


It doesn't look like you are doing anything wrong with the actual function. Relative paths are supported as described below. It's hard to tell without additional information, but does your folder exist in your solution?

You can also, as mentioned, use absolute paths (/ B / childB).

MSDN http://msdn.microsoft.com/en-us/library/ms524632.aspx

4GuyFromRolla http://www.4guysfromrolla.com/webtech/121799-1.shtml

0


source







All Articles