strange character problem

E

Eps

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
B

Bruce Wood

The cheap and nasty way is to do this:

Console.WriteLine("Character code is: {0}",
(int)problemString[problemString.Length - 1]);

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

Eps

Bruce said:
The cheap and nasty way is to do this:

Console.WriteLine("Character code is: {0}",
(int)problemString[problemString.Length - 1]);

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

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

--
Eps

http://ukcomment.blogspot.com/

A UK political Blog
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top