Home All Groups Group Topic Archive Search About

reading text file using streamreader

Author
8 Aug 2006 7:57 PM
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

Author
8 Aug 2006 9:09 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"JM" <j***@ya.com> schrieb:
> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>