c# - What lines have not been read? Streamreader -


i'm developing file reader complex format. there literally hundreds of different entries. in way i'm doing need use 2 streamreaders because need extract information before. these files big enough not read them @ once.

what want notify user lines have not been read. structure this:

streamreader file1 = new streamreader(path); while((line=file1.readline()) != null) {      if(line.startswith("hello") { //... } //... more conditions }    streamreader file2 = new streamreader(path); while((line=file2.readline()) != null) {      if(line.startswith("good morning") { //... } //...more conditions  } 

so if reader perfect @ end lines read. things can bizarre entries can not yet implemented, , want catch lines. problem here, see, having two streamreaders.

my options are:

  1. store in array not read lines , use second reading, subtracting line line after reading it. not because storing several thousand of lines there.
  2. add conditions in second streamreader first (all added) way know lines going read second time. better previous need modify code in several places make run properly. mean, when wanted implement reading new entry (second streamreader) need modify first streamreader too.

is there suggestion or better way of doing this?

i create predicates function translating line, i.e.:

class predicateresult{     public en_linetype type;     public string data; }  private predicateresult firstreader(string line){     if(line.startswith("hello")){         return new predicateresult{             type = en_linetype.hello,             data = ...         }     } } 

that way, have 2 functions can used check if line matches of them. additionaly can easly change condition on matching line , can support different formats.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -