Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

empty lines

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
csharpula csharp - 27 Feb 2008 16:18 GMT
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!
not_a_commie - 27 Feb 2008 17:14 GMT
> 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?
Rene - 27 Feb 2008 19:18 GMT
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?

> Hello,
>
[quoted text clipped - 8 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
Arne Vajhøj - 27 Feb 2008 23:22 GMT
> 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
christery@gmail.com - 28 Feb 2008 02:51 GMT
> > 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.
[quoted text clipped - 20 lines]
>
> 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
csharpula csharp - 28 Feb 2008 09:41 GMT
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!
Jon Skeet [C# MVP] - 28 Feb 2008 09:49 GMT
> 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?

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.