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?
多种方法,但只有一种选择:
new Uri("http://example.com/video.flv?start=5").Segments.Last()
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.