468,110 Members | 1,849 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,110 developers. It's quick & easy.

escape characters in *.settings file

I'm having some trouble storing a string in my settings file that contains
escape characters.
If I enter "This is the first line\r\nand this is the second line."

When I retrieve the string from the settings file I get: "This is the first
line\\r\\nand this is the second line."
It seems to think it's a path or something?

Anyone else dealt with this before? I googled the problem but didn't find
anything (so far).

Thanks for any help,
Steve
Sep 25 '07 #1
2 2498
sklett wrote:
I'm having some trouble storing a string in my settings file that contains
escape characters.
If I enter "This is the first line\r\nand this is the second line."

When I retrieve the string from the settings file I get: "This is the first
line\\r\\nand this is the second line."
It seems to think it's a path or something?
It's not that it thinks it's a path. It's that you have entered a
backslash in your text in the file, and so when you look at the string
in the debugger, the debugger escapes the backslash so that it's clear
that you're looking at a backslash character rather than something else.

I admit, it can actually wind up more confusing rather than less if
you're not used to it. :) But that's the intent anyway.

Now, as for the actual problem, I'm not actually sure what settings file
you're talking about, but if you want to escape characters you're going
to have to go through and convert those escaped characters to what they
represent. For example, string.Replace() where you replace the string
"\\r\\n" with Environment.NewLine.

Pete
Sep 25 '07 #2
Hi Peter,

Thanks for the reply. I will use the Replace() method to make everything
work.

Take care,
Steve

"Peter Duniho" <Np*********@NnOwSlPiAnMk.comwrote in message
news:13*************@corp.supernews.com...
sklett wrote:
>I'm having some trouble storing a string in my settings file that
contains escape characters.
If I enter "This is the first line\r\nand this is the second line."

When I retrieve the string from the settings file I get: "This is the
first line\\r\\nand this is the second line."
It seems to think it's a path or something?

It's not that it thinks it's a path. It's that you have entered a
backslash in your text in the file, and so when you look at the string in
the debugger, the debugger escapes the backslash so that it's clear that
you're looking at a backslash character rather than something else.

I admit, it can actually wind up more confusing rather than less if you're
not used to it. :) But that's the intent anyway.

Now, as for the actual problem, I'm not actually sure what settings file
you're talking about, but if you want to escape characters you're going to
have to go through and convert those escaped characters to what they
represent. For example, string.Replace() where you replace the string
"\\r\\n" with Environment.NewLine.

Pete

Sep 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Matthew Wieder | last post: by
18 posts views Thread by Steve Litvack | last post: by
3 posts views Thread by Guadala Harry | last post: by
131 posts views Thread by Lawrence D'Oliveiro | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.