I have a system developed in Webforms (eca!) that checks the existence of an image and then displays it.
Everything is working correctly, however, when the image path has accents, the File.Exists
method seems to be returning false
.
What can I do to get around this?
Example:
string img1 = Server.MapPath("\Fotos\Imagem.jpg");
string img2 = Server.MapPath("\Fotos\Imagem-com-acentuação.jpg");
Console.WriteLine(File.Exists(img1)); // true
Console.WriteLine(File.Exists(img2)); // false
Update: I wrote and tested the existence of a manually accented file and it worked. I begin to suspect that the problem is in the assembly of the file path, which was done as follows:
string imgUrl = "~\Fotos\Fotos_" + Codigo + "\" + e.Row.Cells[20].Text;