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. Visual Basic
  4. Reading text from Middle of the txt file

Reading text from Middle of the txt file

Scheduled Pinned Locked Moved Visual Basic
7 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.
  • S Offline
    S Offline
    Syed Ali Raza
    wrote on last edited by
    #1

    Hi all; I m reading a txt file from line to line using StreamReader from Begin to End. Now I want that it should read the file where It left it before. from any line which i want. Regards, Ali

    X 1 Reply Last reply
    0
    • S Syed Ali Raza

      Hi all; I m reading a txt file from line to line using StreamReader from Begin to End. Now I want that it should read the file where It left it before. from any line which i want. Regards, Ali

      X Offline
      X Offline
      Xmen Real
      wrote on last edited by
      #2

      set position of StreamReader by this :

      sr.BaseStream.Position

      TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can

      S 1 Reply Last reply
      0
      • X Xmen Real

        set position of StreamReader by this :

        sr.BaseStream.Position

        TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can

        S Offline
        S Offline
        Syed Ali Raza
        wrote on last edited by
        #3

        You mean I should do this. sr.BaseStream.position=10; //where 10 is line No or something else. This is my procedure. using (StreamReader sr = new StreamReader("C:\\Windows\\System32\\Logfiles\\ex080312.log")) { String line; string [] fieldcontent = null; while ((line = sr.ReadLine()) != null) { Response.Write("<br>"+ line); } }

        X 1 Reply Last reply
        0
        • S Syed Ali Raza

          You mean I should do this. sr.BaseStream.position=10; //where 10 is line No or something else. This is my procedure. using (StreamReader sr = new StreamReader("C:\\Windows\\System32\\Logfiles\\ex080312.log")) { String line; string [] fieldcontent = null; while ((line = sr.ReadLine()) != null) { Response.Write("<br>"+ line); } }

          X Offline
          X Offline
          Xmen Real
          wrote on last edited by
          #4

          no, position is for no. of bytes or characters hehe, its VB forum and you are asking bout VC# :rolleyes:

          TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can

          A 1 Reply Last reply
          0
          • X Xmen Real

            no, position is for no. of bytes or characters hehe, its VB forum and you are asking bout VC# :rolleyes:

            TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can

            A Offline
            A Offline
            AndrewVos
            wrote on last edited by
            #5

            So for each line you read, store the position.


            www.wickedorange.com www.andrewvos.com

            S 1 Reply Last reply
            0
            • A AndrewVos

              So for each line you read, store the position.


              www.wickedorange.com www.andrewvos.com

              S Offline
              S Offline
              Syed Ali Raza
              wrote on last edited by
              #6

              Yes I m storing the Line no with each Line. but I want that when I again read this file it should start from where It left.e.g line 10. explain more.

              A 1 Reply Last reply
              0
              • S Syed Ali Raza

                Yes I m storing the Line no with each Line. but I want that when I again read this file it should start from where It left.e.g line 10. explain more.

                A Offline
                A Offline
                AndrewVos
                wrote on last edited by
                #7

                Just store the StreamReader.Position at the same place you're storing the line number, and when you want to read again just set StreamReader.Position = storedposition and you should be able to read the same line again.


                www.wickedorange.com www.andrewvos.com

                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