Here's a complete example using the script_name server variable for the path:
string pagename = System.IO.Path.GetFileName(Request.ServerVariables["SCRIPT_NAME"]);
The pagename string variable will contain "myfile.aspx",
if that code is included in myfile.aspx's Page_Load event or any suitable page event.
Juan T. Llibre, asp.net MVP
aspnetfaq.com :
http://www.aspnetfaq.com/
asp.net faq :
http://asp.net.do/faq/
foros de asp.net, en español :
http://asp.net.do/foros/
===================================
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uW**************@TK2MSFTNGP04.phx.gbl...
Use this function to strip out the filename:
System.IO.Path.GetFileName(sPath)
Here's more info:
http://windowssdk.msdn.microsoft.com...1_16219e3a.asp
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Darrel" <no*****@nospam.com> wrote in message news:Ol**************@TK2MSFTNGP03.phx.gbl... using Request.FilePath will return the entire file path:
directory/directory/myfile.aspx
Is there a built function in ASP.net to grab just the filename (myfile.aspx) or do I need to
write some string manipulation functions to grab it out of the filepath?
-Darrel