It's because you have a combination of SQL and C# character escapes going on.
'\' is a special character in C#: it says "the next character is to be treated as a character, regardless of what it is" and allows us to - for example - insert a double quote into a string:
string s = "Here\"s Johnny!";
So to insert a backslash into a C# string we have to escape the backslash itself:
string t = "back\\slash";
But ... MySql also uses backslash as an escape character:
MySQL :: MySQL 8.0 Reference Manual :: 9.1.1 String Literals[
^]
So in order to insert a backslash into a MySql string from C#, you have to allow for both escape systems:
string u = "INSERT INTO MyTable (MyColumn) VALUES ('D:\\\\temp\\\\filename.txt')";
Or better - pass it as a parameter so the whole horrible mess is mypassed ...