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. Unix File in Windows Stream Reader

Unix File in Windows Stream Reader

Scheduled Pinned Locked Moved C#
help
3 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.
  • C Offline
    C Offline
    CJOakwood
    wrote on last edited by
    #1

    Morning All - I have a unix file / and Stream output that uses ^M [CTRL-M CR (Carriage return) ] to end a line. I see the line break's in MS Wordpad, but not in Notepad or when trying String.Split(char [], ...) I do not know what char to define. Can anybody help, or point me in the right direction. thx, CJ

    H L 2 Replies Last reply
    0
    • C CJOakwood

      Morning All - I have a unix file / and Stream output that uses ^M [CTRL-M CR (Carriage return) ] to end a line. I see the line break's in MS Wordpad, but not in Notepad or when trying String.Split(char [], ...) I do not know what char to define. Can anybody help, or point me in the right direction. thx, CJ

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Are you writing the file or reading it? By default, TextWriter.NewLine is the same as Environment.NewLine. If you need to change this, you can set the NewLine property to any string necessary on classes that extend TextWriter (like StreamWriter). If you're reading files using classes extending the TextReader, many take an optional parameter (via overloads) to the control to automatically detect the file encoding, which most often checks the line-endings as well (IIRC). Take a look at the overloaded constructor documentation for the StreamReader class in the .NET Framework SDK for more information. If you're wondering why wordpad.exe displays ^M it's most likely because it hasn't been updated to handle different line endings while notepad.exe has. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

      1 Reply Last reply
      0
      • C CJOakwood

        Morning All - I have a unix file / and Stream output that uses ^M [CTRL-M CR (Carriage return) ] to end a line. I see the line break's in MS Wordpad, but not in Notepad or when trying String.Split(char [], ...) I do not know what char to define. Can anybody help, or point me in the right direction. thx, CJ

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        string.Split('\n') works just fine for *nix files :) top secret
        Download xacc-ide 0.0.3 now!
        See some screenshots

        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