The issue is that there is an invisible character in your string. I don't know how they get there, others have guessed that the source code went through a program such as Word which modifies the text unbeknownst to you. Or you copied and pasted it from somewhere and that somewhere has the invisible character in it.
As for the character, I found it by first copying your string (if I just type out your string verbatim then it won't have the invisible character, it has to be copied from your text), then deleting everything between the quotes, then using a bitconverter to expose the actual bytes that your IDE displays as an invisible character:
Console.WriteLine(BitConverter.ToString(Encoding.UTF8.GetBytes(@"")));
gives:
E2-80-AA
Which is "Unicode Character 'LEFT-TO-RIGHT EMBEDDING' (U+202A)". Note that @"".Length
returns 1
here because of the 1 invisible character.
This string, which I typed out by hand instead of copying from your string, doesn't have the invisible character: Console.WriteLine(BitConverter.ToString(Encoding.UTF8.GetBytes(@"")));
and just returns a string.Empty with a length of 0.
A solution is to erase that entire string (including the "
's) and just type it out yourself, or highlight only the visible characters between the quotes and copy/paste them into a new string. Here is a fixed string for you: @"D:\links.txt"
, you can copy and paste that in and your problem will be fixed.