Wednesday, March 28, 2012

System.IO.StreamReader is not returning single quotes from my file

I am using a System.IO.StreamReader to read a text file that was created
with Notepad. It is returning everything except the single quotes (at least
that is the only thing I have noticed it is not returning). The code I am
using is:
Dim poemstreamreader As System.IO.StreamReader
poemstreamreader = System.IO.File.OpenText(Global.Poems(poemtitle))
cellPoemText.Text = poemstreamreader.ReadToEnd()
poemstreamreader.Close()
I know that it is reading from the correct file, because it is returning all
the characters correctly, I simply need to know how to make it not discard
special characters such as single quotes. How do I do this? Thanks.
--
Nathan Sokalski
njsokalski@dotnet.itags.org.hotmail.com
http://www.nathansokalski.com/Nathan,
You mean something as

> cellPoemText.Text = poemstreamreader.ReadToEnd()
> poemstreamreader.Close()
cellPoemText.Text = cellPoemText.Text.Replace("'","")
I hope this helps,
Cor
"Nathan Sokalski" <njsokalski@.hotmail.com> schrieb
>I am using a System.IO.StreamReader to read a text file that was
> created with Notepad. It is returning everything except the single quotes
> (at
> least that is the only thing I have noticed it is not returning).
> The code I am using is:
> Dim poemstreamreader As System.IO.StreamReader
> poemstreamreader =
> System.IO.File.OpenText(Global.Poems(poemtitle))
> cellPoemText.Text = poemstreamreader.ReadToEnd()
> poemstreamreader.Close()
>
> I know that it is reading from the correct file, because it is
> returning all the characters correctly, I simply need to know how to
> make it not discard special characters such as single quotes. How do
> I do this?
Don't know if this helps:
poemstreamreader = new io.streamreader(Global.Poems(poemtitle),
system.text.encoding.default)
This assumes ANSI encoding of the file.
Armin

0 comments:

Post a Comment