Reputation: 282995
Given a file path URL such as http://example.com/video.flv?start=5
, I want to get out video.flv
.
Path.GetFileName("http://example.com/video.flv?start=5")
yields video.flv?start=5
, which is more than I want. I can't find anything relevant in the Uri
class either. Am I missing something?
Upvotes: 1
Views: 182
Reputation: 6141
Using Uri.AbsolutePath
I was able to achieve the desired results.
Uri t = new Uri("http://example.com/video.flv?start=5");
Console.WriteLine(t.AbsolutePath);
Console.ReadLine();
printed /video.flv
Upvotes: 0
Reputation: 13579
Various ways, but one option:
new Uri("http://example.com/video.flv?start=5").Segments.Last()
Upvotes: 6