Newline character '\n'

M

Maziar Aflatoun

Hi everyone,

I'm using C# to generate an ics file that gets stored in the database. I
need to add a newline character (\n) to my text file but no matter what I do
it doesn't appear as \n. I have tried \r\n too.

Ex. This is what I need as the end result
This is a \n test

But this is what I'm getting
This is a test

I need to have the \n shown in my text file.

Thank you
Maz.
 
K

Kevin Spencer

Are you sure? Are you looking directly at the text, or viewing it in a
browser, which doesn't render text line feeds, but only HTML breaks?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
M

Martin Dechev

How are you checking the content of the textfile? If you are reading it in
the browser it will not show the linebreaks unless it is in a <pre> element.
To see a linebreak in html you need <br>.

Appart from this, it is recommended to use Environment.NewLine instead of \n
or \r\n.

Hope this helps
Martin
 
M

Matt Hawley

So you don't need the newline to actually appear, just the character representation of it, correct? If so, use \\n instead of just \n

Matt Hawley, MCAD .NET
http://www.eworldui.net

Hi everyone,

I'm using C# to generate an ics file that gets stored in the database. I
need to add a newline character (\n) to my text file but no matter what I do
it doesn't appear as \n. I have tried \r\n too.

Ex. This is what I need as the end result
This is a \n test

But this is what I'm getting
This is a test

I need to have the \n shown in my text file.

Thank you
Maz.



[microsoft.public.dotnet.framework.aspnet]
 

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

Top