<p>I have a page something.aspx, with associated codebehind something.aspx.cs.  In that codebehind, I want to know the filesystem location of something.aspx.  Is there any convenient way to get it?</p>

<p>Update: I got several excellent answers, which unfortunately didn't work because of something else crazy I'm doing.  I'm encoding some additional information on the URL I pass in, so it looks like this:</p>

<p><a href="http://server/path/something.aspx/info1/info2/info3.xml" rel="nofollow noreferrer">http://server/path/something.aspx/info1/info2/info3.xml</a></p>

<p>The server deals with this OK (and I'm not using querystring parameters to work around some other code that I didn't write).  But when I call Server.MapPath(Request.Url.ToString()) I get an error that the full URL with the 'info' segments isn't a valid virtual path.</p>

```
```
// File path
string absoluteSystemPath = Server.MapPath("~/relative/path.aspx");
// Directory path
string dir = System.IO.Path.GetDirectoryName(absoluteSystemPath);
// Or simply
string dir2 = Server.MapPath("~/relative");
```
```