Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定一个文件路径 URL之类的http://example.com/video.flv?start=5,我想出去video.flv。
http://example.com/video.flv?start=5
video.flv
Path.GetFileName("http://example.com/video.flv?start=5")产量video.flv?start=5,这比我想要的要多。Uri我在课堂上也找不到任何相关的东西。我错过了什么吗?
Path.GetFileName("http://example.com/video.flv?start=5")
video.flv?start=5
Uri
多种方式,但一种选择:
new Uri("http://example.com/video.flv?start=5").Segments.Last()
使用Uri.AbsolutePath我能够达到预期的结果。
Uri.AbsolutePath
Uri t = new Uri("http://example.com/video.flv?start=5"); Console.WriteLine(t.AbsolutePath); Console.ReadLine();
打印/video.flv
/video.flv