Newline character '\n'

  • Thread starter Thread starter Maziar Aflatoun
  • Start date Start date
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.
 
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.
 
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
 
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]
 
Back
Top