1

I want to implement a little Dropdown that will show Items that I searched for in a folder.

So, the problem is that I'm German and we have characters like Ä, Ö, Ü etc.

These characters are shown in a strange way. For example, the char Ö is "%c3". Also, spaces are shown as "%20".

Is there a simple way to change them without the string.Replace function?

My code:

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);
}
Heinzi
  • 167,459
  • 57
  • 363
  • 519
DERYANNEK
  • 47
  • 1
  • 9

2 Answers2

3

You can use :

HttpUtility.UrlDecode(myString)

https://msdn.microsoft.com/en-us/library/4fkewx0t(v=vs.110).aspx

Quentin Roger
  • 6,410
  • 2
  • 23
  • 36
2

Here:

HttpUtility.UrlDecode(dir);

you UrlDecode the string and then throw away the result. You probably wanted to write:

dir = HttpUtility.UrlDecode(dir);
Heinzi
  • 167,459
  • 57
  • 363
  • 519