473,587 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

StreamWriter.Wr iteLine() vs .Write("\n") and missing newlines when writing to files with the later

Hi,
When writing using both these methods ( StreamWriter.Wr ite("\n") vs
WriteLine() ) to a file and open in Notepad I see a special character
instead of newlines with Write("\n") vs a newline with WriteLine().

How do I insert characters into a string ( ie "line 1\nline 2\n" ) so that
when I write them to Stream they will be interpreted properly as newlines?

Thanks in advance
Oct 3 '06 #1
2 33869
"Fred Dag" <fr*****@hostvi lleit.comwrote in message
news:e6******** ******@TK2MSFTN GP04.phx.gbl...
[...]
How do I insert characters into a string ( ie "line 1\nline 2\n" ) so that
when I write them to Stream they will be interpreted properly as newlines?
Notepad doesn't understand a single newline character by itself. You need a
carriage return as well ("\r\n").

Alternatively, you can open your file in WordPad, which does treat the
single newline character as a line break.

Pete
Oct 3 '06 #2
Peter Duniho wrote:
"Fred Dag" <fr*****@hostvi lleit.comwrote in message
news:e6******** ******@TK2MSFTN GP04.phx.gbl...
>[...]
How do I insert characters into a string ( ie "line 1\nline 2\n" ) so that
when I write them to Stream they will be interpreted properly as newlines?

Notepad doesn't understand a single newline character by itself. You need a
carriage return as well ("\r\n").
"line 1\r\nline 2" or if one is a portability pedantic
"line 1" + Environment.New Line + "line 2".

Arne
Oct 3 '06 #3

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

Similar topics

1
3246
by: Evgeni Sergeev | last post by:
While I can make a verbatim copy of a file like this: file1 = file('ready.pdf', 'rb') file2 = file('out.pdf', 'wb') buffer = file1.read(256) while buffer: file2.write(buffer) buffer = file1.read(256)
0
2078
by: PeterB | last post by:
Hi! I am using the script below to download files, that are in a non-public directory, from my site. The "smaller files" section works for smaller files. However when the files are getting larger, it won't work! I'm not sure what the size limit is, or if it is some kind of timeout, which would mean very small files if the connection is slow...
5
1919
by: Ben Jeurissen | last post by:
Hello, I have to deal with the following issue in C++: Two threads are started from the main thread, both capturing images from a different firewire camera. Both threads take shots of 460800 bytes at a rate of 30 frames per second. This works fine, without frame loss, and I can display the two framestreams on screen. Now I would like...
5
10792
by: Lyle A. Sieren | last post by:
I posted this earlier with another question but did not explain myself well... How do get a line feed character on the end of a line using the streamwriter.writeline fuction? Following are a list of possible terminators. I need to use the line feed, option 2, instead of the others for the application that will be reading the file. ...
7
2959
by: W. Jordan | last post by:
Hello, I am using Response.WriteFile (filename) to write a file that on the server to my web client. I discover that the while a client request a big file, for example, a 14m-bytes one, the memory usage of the w3wp.exe increases the same amount of 14m. That might be horrible if I allow the users to download a 32m
1
1845
by: shalini0702 | last post by:
Hi, I have Missing Records when exporing a table from (msaccess) One database to another. Supppose My Db has 10 tables and expoting all the table from One database to another was correct. But I created a new table inbetween my 7 th table and 8 th table say Table 7A There after I have noticed that the records exported from 8,9,10 th...
5
8171
by: RyanL | last post by:
I'm a newbie with a large number of data files in multiple directories. I want to uncompress, read, and copy the contents of each file into one master data file. The code below seems to be doing this perfectly. The problem is each of the data files has a header row in the first line, which I do not want in the master file. How can I skip...
2
2160
by: =?Utf-8?B?S3VtYXI=?= | last post by:
I am using granados telnet client for connecting to the telnet and get the data from it. Every thing appears to be going smooth. But for some reason when I try to write the byte data to a string or streamwriter, it looses the final packet. Strangely, If I output the datapackets to a console from the telnet server, it perfectly gets all the...
0
7923
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.