strange character problem

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

    strange character problem

    My program has an ini file which i read in the settings for the program.
    The main setting is the path where files are to be saved. At the
    moment it doesn't work, but if I hardcode the path it does (even though
    the hardcoded path is the same as the one in the ini file).

    I looked at the path in a text box after it had been read in and it had
    a strange character on the end, it was a slim upright rectangle, i
    assume this is the source of my problem. Anyone know how I can read in
    the string without this character ?

    Any help appreciated.

    --
    Eps



    A UK political Blog
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: strange character problem

    Eps,

    In the debugger, I would check the length of the string, and find out
    the value of that character. It is possible that there is some whitespace
    or non printable character that is in the file.

    In either case, you can trim off the whitespace or non printable
    character, or modify the file (I'd cut it out and retype the path in the ini
    file).

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Eps" <eps@mailinator .com> wrote in message
    news:d3m2uu$fg3 $1@domitilla.ai oe.org...[color=blue]
    > My program has an ini file which i read in the settings for the program.
    > The main setting is the path where files are to be saved. At the moment
    > it doesn't work, but if I hardcode the path it does (even though the
    > hardcoded path is the same as the one in the ini file).
    >
    > I looked at the path in a text box after it had been read in and it had a
    > strange character on the end, it was a slim upright rectangle, i assume
    > this is the source of my problem. Anyone know how I can read in the
    > string without this character ?
    >
    > Any help appreciated.
    >
    > --
    > Eps
    >
    > http://ukcomment.blogspot.com/
    >
    > A UK political Blog[/color]


    Comment

    • Eps

      #3
      Re: strange character problem

      Nicholas Paldino [.NET/C# MVP] wrote:[color=blue]
      > Eps,
      >
      > In the debugger, I would check the length of the string, and find out
      > the value of that character.[/color]

      I'm using visual c# 2005 express, how can i view the contents of a
      varible when the program is running ?

      --
      Eps



      A UK political Blog

      Comment

      • Bruce Wood

        #4
        Re: strange character problem

        The cheap and nasty way is to do this:

        Console.WriteLi ne("Character code is: {0}",
        (int)problemStr ing[problemString.L ength - 1]);

        this will print out the character code as an integer. You can then look
        it up in an ASCII table.

        Comment

        • Eps

          #5
          Re: strange character problem

          Bruce Wood wrote:[color=blue]
          > The cheap and nasty way is to do this:
          >
          > Console.WriteLi ne("Character code is: {0}",
          > (int)problemStr ing[problemString.L ength - 1]);
          >
          > this will print out the character code as an integer. You can then look
          > it up in an ASCII table.
          >[/color]

          thanks for everyones help, turns out using the Trim method sorted it.

          --
          Eps



          A UK political Blog

          Comment

          Working...