473,326 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Change NewLine for StreamReader

Hello:

I am reading a rather oddly formatted file being sent to us by an
outside source. I am wondering if there is a way to change what
StreamReader sees as a newline. It is searching for a \r\n, but the
file has newlines set as \r. Obviously, my StreamReader treats the
whole file as one line.

Is there a way to change the newline constant?

Thanks,
Travis
Feb 6 '08 #1
2 2730
Hi,

Frankly I know of no solution for this. The worst case escenario is using
Read() and discard the char if it's a \r
You could use a StringBuilder to hold the read values.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
<je**********@gmail.comwrote in message
news:50**********************************@v67g2000 hse.googlegroups.com...
Hello:

I am reading a rather oddly formatted file being sent to us by an
outside source. I am wondering if there is a way to change what
StreamReader sees as a newline. It is searching for a \r\n, but the
file has newlines set as \r. Obviously, my StreamReader treats the
whole file as one line.

Is there a way to change the newline constant?

Thanks,
Travis

Feb 6 '08 #2
Thank you all. The problem was an encoding problem. I am not sure what
the details are, but when I encoded my file to Unicode, it stopped
working. I probably screwed up while encoding, since I was using a
custom EncodingStream (that I haven't even tested yet).

Thanks, again.
Feb 6 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
7
by: Richard Bond | last post by:
Hi Is there anyway to change the characterset/codepage of a specific textbox on a winform. I have read in a "chinese traditional big5" file into memory using a streamreader with the...
4
by: Peter Kirk | last post by:
Hi I would like to ask a little bit about the value Environment.Newline: what is it and what is the point of it? Ok, I can see in the docs that it represents "newline" for the current platform -...
0
by: Electric Co. | last post by:
Hello, I am trying to write a small xslt utility to build and quickly check my transforms. Unfortunately, I can not figure out how have the output from the transform written to the console with...
3
by: Arpan | last post by:
A file can be read using only the StreamReader object like this: Dim sReader As StreamReader sReader = New StreamReader(Server.MapPath("File1.txt")) While(sReader.Peek -1)...
2
by: kirbybowl | last post by:
I have been using --#SET TERMINATOR to change the delimiter within my CLP scripts. In my situation, the CLP scripts are generated from a database of CLP commands (written by many authors), thus the...
1
by: PSiegmann | last post by:
Hello group, if I open with streamreader a file to read in that way: StreamReader sr = new StreamReader(c:\\test.txt, System.Text.Encoding.GetEncoding(10000)); Is it possible that it can...
0
by: rajana | last post by:
Dear All, We have Ansi file with german characters (Ä / Ø) , We are using Streamreader to read the contents of the file. But Readline() not able to read the German characters. We tried all...
5
by: alex21 | last post by:
I am trying to write a function for determining the data type of columns in a delimited file. However my function is not detecting a newline and exiting the loop after the end of the first line. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.