Reading txt with StreamReader

0

When reading a TXT file, from accounting postings exporting by a third-party system, my problem is in the lines that have the number.

  

VLR REF SIT ANYTHING N ° 1834 MORE TEXT

Using the class StreamReader as follows

using (var reader = new StreamReader(@"D:\Projetos\Syns\Documentação\Contabilidade\exemplo.txt"))
{
    string actual = reader.ReadToEnd();
    Assert.AreEqual("VLR REF ALGUMA COISA Nº 1834 MAIS TEXTO", actual);
}

What I have for return in the current string is

  

VLR REF SIT ANYTHING N ?? 1834 MORE TEXT

I need to return the value equal to the text file.

What kind of     

asked by anonymous 05.12.2017 / 12:38

1 answer

1

The most common is UTF8, but you can also try with ANSI

using (var reader = new StreamReader(@"D:\Projetos\Syns\Documentação\Contabilidade\exemplo.txt", System.Text.Encoding.UTF8))
{
     string actual = reader.ReadToEnd();
     Assert.AreEqual("VLR REF ALGUMA COISA Nº 1834 MAIS TEXTO", actual);
}

EDIT: As seen in the comments, by @RovannLinhalis Enconding.Default was the solution to the problem.

    
05.12.2017 / 12:50