In a C# 2010 application, I have a string value that looks like the following:
"http://localhost:99/test/TestHome.aspx". I only want to obtain the part of the string that is "TestHome.aspx".
I have tried lots of string functions to obtain the "TestHome.aspx" part of the string with no success yet.
Thus can you tell me how to obtain the part of the string I am trying to access?
C# 2010 string
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Posted Jun 21, 2012, 3:00 PM EDT
string pageurl = "http://localhost:99/test/TestHome.aspx";
var idx = pageurl.LastIndexOf("/");
string pagename = pageurl.Substring(idx+1);
Sumit GaudRank #9,090 · 211 reputationPosted Jun 22, 2012, 1:55 AM EDT
string s= Path.GetFileName("http://localhost:99/test/TestHome.aspx ");