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. How can I read something from a text.log file

How can I read something from a text.log file

Scheduled Pinned Locked Moved C#
csharpquestiontutorial
4 Posts 4 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.
  • E Offline
    E Offline
    Eyungwah
    wrote on last edited by
    #1

    HI How can I work with text files in C# .net? For example I want to open a text file, read portion from the file and then display that portion on the pop-up message.

    S C 2 Replies Last reply
    0
    • E Eyungwah

      HI How can I work with text files in C# .net? For example I want to open a text file, read portion from the file and then display that portion on the pop-up message.

      S Offline
      S Offline
      stebo0728
      wrote on last edited by
      #2

      that should not take much code first use a System.IO.FileSteam(fileName, FileMode, FileAccess, FileShare) then pass this stream into a System.IO.StreamReader then use streamReader.ReadLine() to return each line as a String, or there are other options in the stream reader to read from certain offsets, and certain lengths, then whatever data you capture this way can be passed to the MessageBox.Show(message, boxTitle, Buttons, Icon)

      1 Reply Last reply
      0
      • E Eyungwah

        HI How can I work with text files in C# .net? For example I want to open a text file, read portion from the file and then display that portion on the pop-up message.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        System.File.ReadAllLines("c:\text.log"); will give you a string array, ReadAllText will give a single string.

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        M 1 Reply Last reply
        0
        • C Christian Graus

          System.File.ReadAllLines("c:\text.log"); will give you a string array, ReadAllText will give a single string.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          M Offline
          M Offline
          Malcolm Smart
          wrote on last edited by
          #4

          That will teach me to read documentationin advance, not just when I'm stuck. How many times in my code do I open a file, called ReadToEnd, or iterate through the file populating my array manually...:doh: Cheers (again!) Christian for that one.

          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