Unrecognized escape sequence

前端 未结 2 749
误落风尘
误落风尘 2020-12-21 03:55

VS 2005 WinXP

I am writing an application that will connect to a samba share.

However, in my path I am getting an compile error:

unrecognized es         


        
2条回答
  •  庸人自扰
    2020-12-21 04:35

    The compiler sees \\Samba\sun005\admin_config\test.txt as \Samba\sun005\x07dmin_config\x09est.txt. But it just doesn't understand the '\s'.

    It sees \\Samba\\sun005\\admin_config\\test.txt as \Samba\sun005\admin_config\test.txt which the compiler is happy with, but you really need the two slashes at the start. For that you need to use four slashes "\\Samba...."

    @"\\Samba\sun005\admin_config\test.txt" is exactly what you want! You see the extra slashes in the debugger, because the debugger it adding them, so you can see what is really in the string. If you had a newline character in the string, it would display as '\n'.

提交回复
热议问题