473,385 Members | 1,942 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,385 software developers and data experts.

missing CR LF with stream writer

Dear sir,

When I tried to use streamwriter to write a text into a txt file. All the cr
lf in my original text are gone.

Any one know why is that and what should I do???

below is my simple script.
Dim sw As StreamWriter = New StreamWriter("TestFile.txt")
' Add some text to the file.
sw.Write(MyTextVariable)

Thanks.
Nov 19 '05 #1
7 3288
See http://www.dotnet247.com/247referenc...40/203203.aspx

Juan T. Llibre
ASP.NET MVP
===========
"Guoqi Zheng" <no@sorry.com> wrote in message
news:eq**************@TK2MSFTNGP15.phx.gbl...
Dear sir,

When I tried to use streamwriter to write a text into a txt file. All the
cr
lf in my original text are gone.

Any one know why is that and what should I do???

below is my simple script.
Dim sw As StreamWriter = New StreamWriter("TestFile.txt")
' Add some text to the file.
sw.Write(MyTextVariable)

Thanks.

Nov 19 '05 #2
Use WriteLine instead of Write.

Eliyahu

"Guoqi Zheng" <no@sorry.com> wrote in message
news:eq**************@TK2MSFTNGP15.phx.gbl...
Dear sir,

When I tried to use streamwriter to write a text into a txt file. All the cr lf in my original text are gone.

Any one know why is that and what should I do???

below is my simple script.
Dim sw As StreamWriter = New StreamWriter("TestFile.txt")
' Add some text to the file.
sw.Write(MyTextVariable)

Thanks.

Nov 19 '05 #3
Thanks for your answer.

but that is not what I am looking for. I want know why my CR LF is missing.
I don't need to compare CR LF (which is also chr(10), chr(13)) to newline
property, etc.

Any other answer?

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:e$**************@TK2MSFTNGP15.phx.gbl...
See http://www.dotnet247.com/247referenc...40/203203.aspx

Juan T. Llibre
ASP.NET MVP
===========
"Guoqi Zheng" <no@sorry.com> wrote in message
news:eq**************@TK2MSFTNGP15.phx.gbl...
Dear sir,

When I tried to use streamwriter to write a text into a txt file. All the cr
lf in my original text are gone.

Any one know why is that and what should I do???

below is my simple script.
Dim sw As StreamWriter = New StreamWriter("TestFile.txt")
' Add some text to the file.
sw.Write(MyTextVariable)

Thanks.


Nov 19 '05 #4
I should have added that, more exactly, what you need to do
is use the String.Replace method of the .Net Framework's String
class to replace the cr with Char(10) and replace the lf with
Char(13)..

see
http://msdn.microsoft.com/library/de...placetopic.asp

Juan T. Llibre
ASP.NET MVP
===========
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:e$**************@TK2MSFTNGP15.phx.gbl...
See http://www.dotnet247.com/247referenc...40/203203.aspx

Juan T. Llibre
ASP.NET MVP
===========
"Guoqi Zheng" <no@sorry.com> wrote in message
news:eq**************@TK2MSFTNGP15.phx.gbl...
Dear sir,

When I tried to use streamwriter to write a text into a txt file. All the
cr lf in my original text are gone.

Any one know why is that and what should I do???

below is my simple script.
Dim sw As StreamWriter = New StreamWriter("TestFile.txt")
' Add some text to the file.
sw.Write(MyTextVariable)

Thanks.


Nov 19 '05 #5
Eliyahu,

Would

sw.Write(NewLine);

also work ?

Juan T. Llibre
ASP.NET MVP
===========
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Use WriteLine instead of Write.

Eliyahu

"Guoqi Zheng" <no@sorry.com> wrote in message
news:eq**************@TK2MSFTNGP15.phx.gbl...
Dear sir,

When I tried to use streamwriter to write a text into a txt file. All the

cr
lf in my original text are gone.

Any one know why is that and what should I do???

below is my simple script.
Dim sw As StreamWriter = New StreamWriter("TestFile.txt")
' Add some text to the file.
sw.Write(MyTextVariable)

Thanks.


Nov 19 '05 #6
Juan,

You mean sw.Write(sw.NewLine). Sure.
The original post leaves some room for interpretation, so the responses
could miss the point.

Eliyahu

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Eliyahu,

Would

sw.Write(NewLine);

also work ?

Juan T. Llibre
ASP.NET MVP
===========
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
Use WriteLine instead of Write.

Eliyahu

"Guoqi Zheng" <no@sorry.com> wrote in message
news:eq**************@TK2MSFTNGP15.phx.gbl...
Dear sir,

When I tried to use streamwriter to write a text into a txt file. All
the cr
lf in my original text are gone.

Any one know why is that and what should I do???

below is my simple script.
Dim sw As StreamWriter = New StreamWriter("TestFile.txt")
' Add some text to the file.
sw.Write(MyTextVariable)

Thanks.



Nov 19 '05 #7
re:
You mean sw.Write(sw.NewLine).
Yes. My fingers sometimes have a mind of their own.

;-)

re:
Sure.
I thought so.

Thanks!
Juan T. Llibre
ASP.NET MVP
===========
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:eo**************@TK2MSFTNGP14.phx.gbl... Juan,

You mean sw.Write(sw.NewLine). Sure.
The original post leaves some room for interpretation, so the responses
could miss the point.

Eliyahu

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Eliyahu,

Would

sw.Write(NewLine);

also work ?

Juan T. Llibre
ASP.NET MVP
===========
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:O9**************@TK2MSFTNGP15.phx.gbl...
> Use WriteLine instead of Write.
>
> Eliyahu
>
> "Guoqi Zheng" <no@sorry.com> wrote in message
> news:eq**************@TK2MSFTNGP15.phx.gbl...
>> Dear sir,
>>
>> When I tried to use streamwriter to write a text into a txt file. All

the > cr
>> lf in my original text are gone.
>>
>> Any one know why is that and what should I do???
>>
>> below is my simple script.
>> Dim sw As StreamWriter = New StreamWriter("TestFile.txt")
>> ' Add some text to the file.
>> sw.Write(MyTextVariable)
>>
>> Thanks.

Nov 19 '05 #8

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

Similar topics

18
by: JG | last post by:
Does anyone know a standard (or supported on Linux, Mac, Win32) way to clear a read stream buffer (standard ANSI C file stream)? I would even settle for a platform specific way of doing it. ...
5
by: andrewcw | last post by:
I have an object to serialize. TextWriter writer = new StreamWriter("test.xml"); serializer.Serialize(writer,obj); writer.Close(); but below does not, why ?? I have a file that I will have...
1
by: Martin | last post by:
Hi Im trying to make a Client/Server where im going to encrypt the stream but i cant get it to work. I can recieve and send as long as im not trying to send/recieve encrypted. but when i am i cant...
0
by: a | last post by:
Save text file as html kloepper 17:42 23 Jul '04 I'm using httpwebresponse and a StringBuilder to return a stream that originates as a file with the .txt suffix (My download code converts the html...
1
by: Ryan Ternier | last post by:
I'm writing a file out using StreamWriter. What i'm outputting is a 6,398 lines of stupid Jscript arrays. Yes the system needs to be very very dynamic, and they don't want a page reload. The...
8
by: Marc Gravell | last post by:
I want to write a method that will accept a stream as a parameter, and which will write xml to the stream (based in reality on database results) using the XmlTextWriter class. However, this insists...
7
by: .... | last post by:
Hi I have an existing function which has a stream object (inmsg.BodyPart.Data). I'm trying to search and replace the stream object in the most efficient way possible This is my attempt below,...
10
by: John Kraft | last post by:
Hello all, I'm experiencing some, imo, strange behavior with the StreamReader object I am using in the code below. Summary is that I am downloading a file from a website and saving it to disk...
2
by: Mikus Sleiners | last post by:
I'm trying to write new stream from string and i can't figure out why my memory stream instance is null after i have writen to it with stream writer. Here is an example. MemoryStream stream =...
1
by: pax82 | last post by:
hi, sorry for my english but i don't speak good english. in this web service i send 2 data stream(xml and xsl file) and i would like to return a xslt trasform-file byte array (now i return string...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...

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.