如何在windows phone 8.1中用Url中的%20填补空白
本文关键字:Url 中用 中的 填补空白 windows phone | 更新日期: 2023-09-27 18:21:00
我尝试过WebUtility.UrlEncode和Uri.UnescapeDataString,但它正在对整个url进行编码,但我只想用%20来填补空白。我的代码在下面。
string url = "https://www.example.com/images/catalog/operators/Ajmer Vidyut Vitran Nigam.png";
//Method1
string imageUrl = WebUtility.UrlEncode(url);
//Method2
string temp = Uri.EscapeDataString(url);
编码后的实际url:"https%3A%2F%2Fassetscdn.paytm.com%2Fimages%2Fcatalog%2Foperators%2FAjmer+Vidyut+Vitran+Nigam.png"
需要url:"https://assetscdn.paytm.com/images/catalog/operators/Ajmer%20Vidyut%20Vitran%20Nigam.png"
提前感谢:)
使用Uri.EscapeUriString
string imageUrl = Uri.EscapeUriString(url);
您可以使用HttpUtility.UrlPathEncode方法(字符串)。点击此处查看更多信息