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 to read rext file?

how to read rext file?

Scheduled Pinned Locked Moved C#
helpcsharpsalestutorialquestion
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.
  • P Offline
    P Offline
    P_Elza
    wrote on last edited by
    #1

    hi friends i want to read a txt file using c#. i have some txt files with different informations. ex

       txt 1
    

    customr:abc
    article:zxy
    page number: 4

        txt 2
    

    customr:fgh
    article:ser
    page number: 3

    txt 3
    customr:yhu
    article:fgr
    page number:10

    the problem is : how i can find the value. how to read this txt file. i tried. but it is reading only if we fave given the full length. i want to find what will be the value of customer of txt 1. plz do help me. thank u.

    A R 2 Replies Last reply
    0
    • P P_Elza

      hi friends i want to read a txt file using c#. i have some txt files with different informations. ex

         txt 1
      

      customr:abc
      article:zxy
      page number: 4

          txt 2
      

      customr:fgh
      article:ser
      page number: 3

      txt 3
      customr:yhu
      article:fgr
      page number:10

      the problem is : how i can find the value. how to read this txt file. i tried. but it is reading only if we fave given the full length. i want to find what will be the value of customer of txt 1. plz do help me. thank u.

      A Offline
      A Offline
      Andrei Ungureanu
      wrote on last edited by
      #2

      string text = File.ReadAllText(filename)

      You can then search for different strings within your string using IndexOf, Substring etc. If you don't like this approach study MDSN for System.IO.File class. It has a lot of static methods that can help you read a text file in different ways.

      Do your best to be the best

      1 Reply Last reply
      0
      • P P_Elza

        hi friends i want to read a txt file using c#. i have some txt files with different informations. ex

           txt 1
        

        customr:abc
        article:zxy
        page number: 4

            txt 2
        

        customr:fgh
        article:ser
        page number: 3

        txt 3
        customr:yhu
        article:fgr
        page number:10

        the problem is : how i can find the value. how to read this txt file. i tried. but it is reading only if we fave given the full length. i want to find what will be the value of customer of txt 1. plz do help me. thank u.

        R Offline
        R Offline
        rajansethi
        wrote on last edited by
        #3

        You can use the readline function of the StreamReader. If the line contains the desired text such as txt 1, then read the next line and you will get the customer name etc.

        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