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. Problem with StreamReader.BaseStream.Position

Problem with StreamReader.BaseStream.Position

Scheduled Pinned Locked Moved C#
helpcsstestingbeta-testingregex
1 Posts 1 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.
  • A Offline
    A Offline
    AfzalHassen
    wrote on last edited by
    #1

    Hi, Heres an example of what i am doing now... line 01 RECORD 1 ,RECORD 2 ,RECORD 3 line 02 data,data,data line 03 data, ,data line 04 data,data,data line 05 RECORD 4 ,RECORD 5 ,RECORD 6 line 06 data,data,data line 07 data,data,data line 08 ,data, line 09 data, ,data line 10 RECORD 4 ,RECORD 5 ,RECORD 6 line 11 data,data,data line 12 data, ,data line 13 data,data,data I am iterating through the file line by line, because the data between the blocks of records are inconsistent, i'm using regular expresion to test for the begining of the next record so that i know what data to process. the problem is that the method that is making use of this piece of code is required to return only 1 record at any one time. i have managed to solve the 1 record at a time issue by keeping track of the records that were returned and then following a few other steps. Because I'm testing for the beginning of the next record, the StreamReader will alwaus pass the point at which I need to be in order to read the next block of records that I need to process. i.e line I have tried moving the position of the base stream to less than to where/what it currently is by doing the following.. _myFile.BaseStream.Position = _myFile.BaseStream.Position - _previousLineData.Length; but this doesn't work :( In addition, both overloads of the Peek() method of the StreamReader are of no use to me (since they only peek for characters without advancing the StreamReader) and i need to read the whole line to test the RegEx in order to determine whether i have reached the end of a block of records. as can be seen by the generic sample of the file data above, the data in the file is not well organised and or managed. any help/hints and advice will be much appreciated.. Thanks a million Afzal Hassen

    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