reading text file using streamreader

J

JM

Hi,

I have been trying to read a file, using "StreamReader" to pass the info to
an string that is:

....dim stream as new FileStream(file,...)
dim sr as new StreamReader(stream)
dim data as string = sr.ReadToEnd...

My problem is that in the file (is a text file) there is some data like:

"... the company name is ¨CalifEx¨ and is located in ¨Austin¨..."

when I use the streamreader to read the above text its returns:

"... the company name is CalifEx and is located in Austin..."

So streamreader miss the small doublequotes surrounding CalifEx and Austin.

I think that some kind of encoding must be used before I read the file.

How?, Any help??

Thanks,

jamie
 
H

Herfried K. Wagner [MVP]

JM said:
I have been trying to read a file, using "StreamReader" to pass the info
to an string that is:

...dim stream as new FileStream(file,...)
dim sr as new StreamReader(stream)
dim data as string = sr.ReadToEnd...

My problem is that in the file (is a text file) there is some data like:

"... the company name is ¨CalifEx¨ and is located in ¨Austin¨..."

when I use the streamreader to read the above text its returns:

"... the company name is CalifEx and is located in Austin..."

So streamreader miss the small doublequotes surrounding CalifEx and
Austin.

Those characters are no "standard" double quote characters.

Which encoding has been used to store the file? You may want to pass
'System.Text.Encoding.Default' to the 'StreamReader' constructor in order to
use the system's Windows-ANSI codepage to read the file.
 

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