
It’s pretty obvious that the question marks relate to the non-ASCII characters, and each name on my list have either an accent or a grave, or an umlaut/diaeresis.

What’s gone wrong? The StreamReader object and original text file need to have compatible encoding types I expected to see my team’s names written to the console – but instead all those names now have question marks scattered throughout them, as shown in the image below. WriteLine( "The file could not be read:") īut when I run the code, there’s a problem. Read the stream to a string, and write the string to the console. So I’ve written a spike of code to use a StreamReader – I’ve more or less copied directly from the link above – and it looks like this: using System Ĭonst string myTeamNamesFile = using ( var streamReader = new StreamReader(myTeamNamesFile))

NET Framework StreamReader – there’s a simple and clear example on the site describing how to do this. I’m going to read names from this text file using a.

I saved the file with the default ANSI encoding. I created the text file on Windows 10 machine and used Notepad. The file is pretty simple – it’s called MyTeamNames.txt and it contains the following names: I’ve got a list of my team members in a text file which I need to parse and process in.
