我想要实现一个小下拉列表,它将显示我在文件夹中搜索的项目。
所以,问题是,我是德国人,我们有这样的角色,像,厄厄,聚聚等。
这些人物以一种奇怪的方式表现出来。例如,char是"%c3“。此外,空格显示为"%20“。
有没有一种不使用string.Replace
函数来更改它们的简单方法?
我的代码:
try
{
string dirPath = (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) +
"\\Arma 3 - Other Profiles");
List<string> dirs = new List<string>(Directory.EnumerateDirectories(dirPath));
foreach (var dir in dirs)
{
HttpUtility.UrlDecode(dir);
MessageBox.Show(dir);
comboBox1.Items.Add(dir.ToString());
}
}
catch (UnauthorizedAccessException UAEx)
{
Console.WriteLine(UAEx.Message);
}
catch (PathTooLongException PathEx)
{
Console.WriteLine(PathEx.Message);
}
发布于 2015-12-22 12:32:24
在此:
HttpUtility.UrlDecode(dir);
您可以UrlDecode字符串,然后丢弃结果。你可能想写:
dir = HttpUtility.UrlDecode(dir);
发布于 2015-12-22 10:51:12
您可以使用:
HttpUtility.UrlDecode(myString)
https://msdn.microsoft.com/en-us/library/4fkewx0t(v=vs.110).aspx
https://stackoverflow.com/questions/34422353
复制相似问题