C# 需要:.Net帮助程序处理url路径
我需要对如下URL进行一些处理:C# 需要:.Net帮助程序处理url路径,c#,asp.net,.net,C#,Asp.net,.net,我需要对如下URL进行一些处理: https://www.myurl.com/deep/path/file.rdp?q=true 我需要将其更改为: https://www.myurl.com/deep/z.asmx 这条路可以走得更深 在处理文件时,我使用System.IO.Path进行修改 有没有一种不用进行大量字符串操作就可以使用url路径的好方法 var uri = new Uri("https://www.myurl.com/deep/path/file.rdp?q=true");
https://www.myurl.com/deep/path/file.rdp?q=true
我需要将其更改为:
https://www.myurl.com/deep/z.asmx
这条路可以走得更深
在处理文件时,我使用System.IO.Path
进行修改
有没有一种不用进行大量字符串操作就可以使用url路径的好方法
var uri = new Uri("https://www.myurl.com/deep/path/file.rdp?q=true");
var parts = uri.Segments;
零件将是/
deep/
path/
file.rdp
string sResult =
Regex.Replace("http://site.com/page1.php?par=true", @"(?<=/)[^/]*$", "z.asmx");
零件将是/
deep/
path/
file.rdp
字符串sResult=
string sResult =
Regex.Replace("http://site.com/page1.php?par=true", @"(?<=/)[^/]*$", "z.asmx");
Regex.Replace(“http://site.com/page1.php?par=true“,@”(?string sResult=
Regex.Replace(“http://site.com/page1.php?par=true“,@”(?我应该把段放在堆栈上并弹出它们吗?@KeesC.Bakker我想你只需要段[1]
路径可以比这更深;-)@KeesC.Bakker这是一个字符串[]
无需使用任何结构。我是否应该将段放在堆栈上并弹出它们?@KeesC.Bakker我认为您只需要段[1]
路径可以比这更深;-)@KeesC.Bakker它是一个字符串[]
无需使用任何结构。