In .NET 4.0, whats the equivalent function to IO.Path.GetFileName
for urls?
The Uri class is your friend.
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI.
IsFile
will try to determine if the Uri
does indeed point to a file.
Use the Segements
property in order to get the file name (it will be the last segment).
Uri uri = new Uri("http://example.com/title/index.htm");
var filename = uri.Segments[uri.Segments.Length - 1];
// filename == "index.htm"