Click here to Skip to main content
15,889,842 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi Please i try to use this string in c# string
My string
reg add "\\10.10.10.10\a\b_b\c c\d" /f




Please help me
Posted
Updated 13-Jul-14 21:25pm
v2
Comments
Thanks7872 14-Jul-14 3:09am    
And help you with what?

All those slash/backslash drives C# crazy...
The reason is that \ is THE escape character[^] of all the C family languages...
Fortunately you can use @ to declare string literals that can hold such content - http://msdn.microsoft.com/en-us/library/aa691090(v=vs.71).aspx[^]
 
Share this answer
 
change "\\10.10.10.10\a\b_b\c c\d" /f to "\\\\10.10.10.10\\a\\b_b\\c c\\d" /f. i.e. use escape sequence.
 
Share this answer
 
v2
Comments
sam9787 14-Jul-14 3:12am    
I try to use this
But i got error
String st="reg add "\\10.10.10.10\a\b_b\c c\d" /f"
ArunRajendra 14-Jul-14 4:12am    
Try this String st="reg add ""\\\\10.10.10.10\\a\\b_b\\c c\\d"" /f"
Matt T Heffron 14-Jul-14 13:11pm    
NOOOOOO!!!!!!
Use the features of the language!
See Kornfeld Eliyahu Peter's solution.
String st=@"reg add ""\\10.10.10.10\a\b_b\c c\d"" /f";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900