escape characters in *.settings file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sklett

    #1

    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


  • Peter Duniho

    #2
    Re: escape characters in *.settings file

    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.New Line.

    Pete

    Comment

    • sklett

      #3
      Re: escape characters in *.settings file

      Hi Peter,

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

      Take care,
      Steve

      "Peter Duniho" <NpOeStPeAdM@Nn OwSlPiAnMk.comw rote in message
      news:13fit3hnnq tl188@corp.supe rnews.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.New Line.
      >
      Pete

      Comment

      Working...