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 escape sequence
The path I am using is this:
string path = "\\Samba\sun005\admin_config\test.txt";
I have also tried the following using double backlashes:
string path = "\\Samba\\sun005\\admin_config\\test.txt";
However, the above compiles ok, but when it runs it complains "cannot find the path"
Also tried the following:
string path = @"\\Samba\sun005\admin_config\test.txt";
When I check in the debugger I get the following string
\\Samba\\sun005\\admin_config\\test.txt
I get access denied in my exception. Now that I am thinking about it. I haven't set the username and password. I think that is my problem.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With