简体   繁体   English

从网址中删除%20

[英]Remove %20 From the Url

I have a problem: 我有个问题:

System.IO.Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath)

This statement gives %20 for me. 此声明为我提供%20。 I want to remove this. 我想删除它。 Is there any way other than replace? 除了替换之外还有什么方法吗?

You can use HTTPUtility.URLDecode to remove %20 and any other encoded characters. 您可以使用HTTPUtility.URLDecode删除%20和任何其他编码字符。 It won't actually remove it, but rather, replace it with a space, as that is what it represents. 它实际上不会删除它,而是用空格替换它,因为它代表了它。 If you actually want it removed completely, you have to use replace. 如果你真的希望它完全删除,你必须使用替换。

使用System.Web.HttpUtility.UrlDecode [ MSDN ]代替字符串替换。

应用以下正则表达式: s/%20/ /g

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM