Your code contains an escaped backslash. C# is converting \\
to a single \
:
string Text = ".\\MyExample.txt"; // Text == ".\MyExample.txt"
If you want Text to contain \\
, use one of the following methods:
string Text = @".\\MyExample.txt";
string Text = ".\\\\MyExample.txt";