Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
Well, to start with here is the code

config.Set("Silk", txt_silkdir.Text+"\silkroad.exe")


And the thing cause the UNRECONIZED ESCAPE SEQUENCE error is the part were it is like "\silkroad.exe"

The thing is i need it to have the \ infront of the filename because i do not know how to add a trailing \ to the folderBrowserDialog selectePath

Any help would be apreciated.
Posted
Updated 11-Oct-10 4:22am
v2

Use the @ or \ escape sequence character.

config.Set("Silk", txt_silkdir.Text+ @"\silkroad.exe")

OR

config.Set("Silk", txt_silkdir.Text+ "\\silkroad.exe")
 
Share this answer
 
In a normal C# string, the '\' character introduces an Escape Sequence - a way of getting characters into a string that you either can't type (e.g. Newline: '\n') or which are part of the string syntax (e.e. double quotes '\"').
There are two ways around this:
1) Prefix your string with a '@' charcater, in which case '\' ceases to be an escape sequence introducer.
config.Set("Silk", txt_silkdir.Text+@"\silkroad.exe")

or

2) Use the escape squence '\\' instead which produces a single '\' as part of your string.
config.Set("Silk", txt_silkdir.Text+"\\silkroad.exe")
 
Share this answer
 
Comments
WALEED SHAKER 11-Oct-10 11:26am    
yes in c# you can use \\ so you get \

\" so you get "

happy learning
OriginalGriff 11-Oct-10 12:11pm    
Waleed, I think I know that. I did say so in my answer.
I think you need to look at which buttons to press - you probably meant to reply to the OP, rather than leave a comment on my answer!

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