Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do this one of three ways:</p> <p>1) Write your own StreamReader. Here's a good place to start: <a href="https://stackoverflow.com/questions/829568/how-to-know-positionlinenumber-of-a-streamreader-in-a-textfile">How to know position(linenumber) of a streamreader in a textfile?</a></p> <p>2) The StreamReader class has two very important, but private variables called charPos and charLen that are needed in locating the actual "read" position and not just the underlying position of the stream. You could use reflection to get the values as suggested <a href="http://www.daniweb.com/software-development/csharp/threads/35078/streamreader-and-position" rel="nofollow noreferrer">here</a> </p> <blockquote> <pre><code>Int32 charpos = (Int32) s.GetType().InvokeMember("charPos", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField ,null, s, null); Int32 charlen= (Int32) s.GetType().InvokeMember("charLen", BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField ,null, s, null); return (Int32)s.BaseStream.Position-charlen+charpos; </code></pre> </blockquote> <p>3) Simply read the entire file into a string array. Something like this:</p> <blockquote> <pre><code>char[] CRLF = new char[2] { '\n', '\r' }; TextReader tr = File.OpenText("some path to file"); string[] fileLines = tr.ReadToEnd().Split(CRLF); </code></pre> </blockquote> <p>Another possibility (along the sames lines as #3) is to read in the lines and store the line in an array. When you want to read the prior line, just use the array.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload