Unrecognized escape sequence

前端 未结 2 729
误落风尘
误落风尘 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:29

    A UNC path should just include the machine name, the share name, an the path relative to the share point (inclusion of a "samba" scheme is not necessary). In the case of the machine name being sun005, either of the two following should work:

    "\\\\sun005\\admin_config\\test.txt"
    @"\\sun005\admin_config\test.txt"
    
    0 讨论(0)
  • 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'.

    0 讨论(0)
提交回复
热议问题