By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,028 Members | 1,092 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,028 IT Pros & Developers. It's quick & easy.

Read Text From Stream Then Reposition And Repeat

P: n/a
Thanks to all...

I need to read a block of text, operate on the read text then move to the
next text block and so on and so on from a 650MB file.

Pseudo code would be something like this:

1. Start at the beginning of the text file
2. Read in 100K of text
3. Work with the 100K of text
4. Repostion the cursor to the start of the next text block (position now
100001)
5. Read in 100K of text
6. Work with the 100K of text
7. Repostion the cursor to the start of the next text block (position now
200001)
8. Read in 100K of text
9. etc

I'm thinking that I need to use the StreamReader.Read function. Is this the
best approach? What approach will be the fastest?

Thanks very much

-- ty_92648 AT hotmail.com
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<"Garibaldi" <ty_92648 AT hotmail.com>> wrote:
Thanks to all...

I need to read a block of text, operate on the read text then move to the
next text block and so on and so on from a 650MB file.

Pseudo code would be something like this:

1. Start at the beginning of the text file
2. Read in 100K of text
3. Work with the 100K of text
4. Repostion the cursor to the start of the next text block (position now
100001)
5. Read in 100K of text
6. Work with the 100K of text
7. Repostion the cursor to the start of the next text block (position now
200001)
8. Read in 100K of text
9. etc

I'm thinking that I need to use the StreamReader.Read function. Is this the
best approach? What approach will be the fastest?


Why bother repositioning? Just read in the first 100K, then read in the
next 100K with the same StreamReader, etc.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

P: n/a
Hi,

If you are reading text the best way of doing it is using StreamReader
class
Now depending of what you are doing you can use two approachs
1- treat the reading as lines using ReadLine() and keeping them in a
string[]
2- treat the text as a group of char and reading then on a char[] as you
proposed. if you dont need to keep track of lines this is the best way

Btw, you don;t need to reposition the stream, unless that you need to write
back the modified data (which is entirely another matter ).

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Garibaldi" <ty_92648 AT hotmail.com> wrote in message
news:eu**************@TK2MSFTNGP10.phx.gbl...
Thanks to all...

I need to read a block of text, operate on the read text then move to the
next text block and so on and so on from a 650MB file.

Pseudo code would be something like this:

1. Start at the beginning of the text file
2. Read in 100K of text
3. Work with the 100K of text
4. Repostion the cursor to the start of the next text block (position now
100001)
5. Read in 100K of text
6. Work with the 100K of text
7. Repostion the cursor to the start of the next text block (position now
200001)
8. Read in 100K of text
9. etc

I'm thinking that I need to use the StreamReader.Read function. Is this the best approach? What approach will be the fastest?

Thanks very much

-- ty_92648 AT hotmail.com

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.