StreamReader-how to read previous line


i have buttons "showmore" , "previous".

the show more reads 5 llines , stores array.

but cant seem make "previous" button work, want "previous" button read previous 5 lines , store in array.

is there way , read lines?

example: read first 10 lines, how can read previous 5 lines without having store content of text file array.

i been checking possible ways streamreader not have way read specific line, i'm trying avoid storing entire text file array efficiency 


the simplest thing use list (or array) john wein suggests i.e. use readalllines fill list/array , can scroll , forwards heart's content.

however, if file extremely large may problem. in cases won't be. if it how depends on file extent. e.g. if lines in file same size easy go particular line using seek (see bufferedstream in help). if not same size there structure lines might still possible - more complex calculate position seek.

if go john's suggestion unless turns out file huge.


regards david r
---------------------------------------------------------------
great thing object oriented code can make small, simple problems large, complex ones.
object-oriented programming offers sustainable way write spaghetti code. - paul graham.
every program becomes rococo, , rubble. - alan perlis
valid measurement of code quality: wtfs/minute.



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'