I have the following URL:
www.mysite.com/type/text.gif
www.mysite.com/type/video.gif
www.mysite.com/gettype.php?giveme=text.gif
www.mysite.com/gettype.php?giveme=video.gif
I have the following code to extract the file name from url:
var type = System.IO.Path.GetFileNameWithoutExtension("www.mysite.com/type/text.gif"); // text
type = System.IO.Path.GetFileNameWithoutExtension("www.mysite.com/type/video.gif"); // video
type = System.IO.Path.GetFileNameWithoutExtension("www.mysite.com/gettype.php?giveme=text.gif"); // gettype.php?giveme=text
type = System.IO.Path.GetFileNameWithoutExtension("www.mysite.com/gettype.php?giveme=video.gif"); // gettype.php?giveme=video
On the first two links I got the expected result - the file name but on the last two results I don't get the expected result, How can I got the file name from any url?