empty lines

  • Thread starter Thread starter csharpula csharp
  • Start date Start date
C

csharpula csharp

Hello,

I read a file via Stream Reader which is associated with web response
from linux server and using Stream Writer to write to a text file.
I read a text file and for some reason I read an extra empty line which
is not part of the file.Why can it happen? Maybe it has something to do
with Linux via Windows ?
I did : streamReader.NewLine ="\n" and it didn't help.
Why is that?
Thanks!
 
I did : streamReader.NewLine ="\n" and it didn't help.

Try "\r\n" or just "\r". Does Stream Reader have a text/binary mode
toggle? If you read the file with File.ReadAllText variants do you see
the same problem?
 
Is my understanding that operating systems like Linux will used LF (line
feed) to represent a new line where operating systems such as Microsoft
Windows use CR+LF (Carriage return + Line Feed) to represent a new line.

Could this be the cause of your problems?
 
csharpula said:
I read a file via Stream Reader which is associated with web response
from linux server and using Stream Writer to write to a text file.
I read a text file and for some reason I read an extra empty line which
is not part of the file.Why can it happen? Maybe it has something to do
with Linux via Windows ?

My guess is that the web server returned:

line 1<CR><LF>
line 2<CR><LF>
....
line n<CR><LF>

which turns out to be:

line 1
line 2
....
line n
(blank line)

And I would not really consider it a problem.

Arne
 
My guess is that the web server returned:

line 1<CR><LF>
line 2<CR><LF>
...
line n<CR><LF>

which turns out to be:

line 1
line 2
...
line n
(blank line)

And I would not really consider it a problem.

Arne

Or reading between the lines...

line 1
(blank line)
line 2
(blank line)
...
(blank line)
line n
(blank line)

Go for the CR/LF translation problem, got some of the same from VMS,
but lacking breaks, so the text is just one line, but
looooooooooong...
//CY
 
Hello again,
My problem is te empty line in the end of te stream. I tried all the
options of "/n","/r","/n/r" and nothing helps.
Is there any thing I can mplement (except for adding if for ignoring) in
order not to read this empty line in the end?
Thanks a lot!
 
csharpula csharp said:
My problem is te empty line in the end of te stream. I tried all the
options of "/n","/r","/n/r" and nothing helps.
Is there any thing I can mplement (except for adding if for ignoring) in
order not to read this empty line in the end?

How sure are you that the empty line doesn't exist in the original
file? Many files *do* end with an empty line. What's the binary data at
the end of 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

Similar Threads


Back
Top