Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Um, NewLine char ain't workin' nomore.

Um, NewLine char ain't workin' nomore.

Scheduled Pinned Locked Moved C#
question
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jas0n23
    wrote on last edited by
    #1

    Hi all, I'm using \n to create a new line when I wrote to a text file. Here's how I'm writing the string: File.AppendAllText(destinationpath.Text, "Hi, this is a\n multiline\n text\n file."); Now, it's not working.When I open the text file that was created, the whole thing's just a single line, but where the new line should have been created, there is a weird-looking square in its place. I've used \n to create new lines in the past and it worked perfectly but it doesn't want to work anymore. Does anyone have any ideas? Jay.

    foreach( inch on Jason ) { Girlfriend.IsHappier(); }

    D J 2 Replies Last reply
    0
    • J jas0n23

      Hi all, I'm using \n to create a new line when I wrote to a text file. Here's how I'm writing the string: File.AppendAllText(destinationpath.Text, "Hi, this is a\n multiline\n text\n file."); Now, it's not working.When I open the text file that was created, the whole thing's just a single line, but where the new line should have been created, there is a weird-looking square in its place. I've used \n to create new lines in the past and it worked perfectly but it doesn't want to work anymore. Does anyone have any ideas? Jay.

      foreach( inch on Jason ) { Girlfriend.IsHappier(); }

      D Offline
      D Offline
      Dino Mulahusic
      wrote on last edited by
      #2

      Try this

      File.AppendAllText(destinationpath.Text, "Hi, this is a" + Environment.NewLine + " multiline...");

      J 1 Reply Last reply
      0
      • J jas0n23

        Hi all, I'm using \n to create a new line when I wrote to a text file. Here's how I'm writing the string: File.AppendAllText(destinationpath.Text, "Hi, this is a\n multiline\n text\n file."); Now, it's not working.When I open the text file that was created, the whole thing's just a single line, but where the new line should have been created, there is a weird-looking square in its place. I've used \n to create new lines in the past and it worked perfectly but it doesn't want to work anymore. Does anyone have any ideas? Jay.

        foreach( inch on Jason ) { Girlfriend.IsHappier(); }

        J Offline
        J Offline
        J4amieC
        wrote on last edited by
        #3

        newlines are actually carrige return + linefeed. which for you is \r\n or use Environment.Newline as suggested above.

        1 Reply Last reply
        0
        • D Dino Mulahusic

          Try this

          File.AppendAllText(destinationpath.Text, "Hi, this is a" + Environment.NewLine + " multiline...");

          J Offline
          J Offline
          jas0n23
          wrote on last edited by
          #4

          Yay! Thanks afree it worked.

          foreach( inch on Jason ) { Girlfriend.IsHappier(); }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups