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

VB 2005 question regarding reading text files

P: 1
Hi there,

I am writing a code to read some data from the text files. The number of text files is not fixed and could be more that 15. the length of each file is large... close to 100,000 on an average. some of them are extra large. The data that I have to read will always be at the bottom and will be in the last 5 -20 line in the files depending upon their size. small files will have 5 line and large files will have 20 lines to read.

Can you people suggest me an easy way to do it. If I read all the files from top and look for a particular word to start storing data..with 15 file it will take a lot of time.

is there are way to read from bottom... or count the number of line and start reading from no. of line - 20....

or any other easy ways??

please let me know..

thanks... please keep in mind that i am a begineer...
Jul 26 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
You could start at the end of the file and jump back a bit repeatedly until you find the start of the line you want. When you open a file in Binary mode, you can skip around to any point in the file.

Are the last 5/20 lines of a fixed size? Do you know what their maximum size is?

I'd throw together some code to try out the idea, but I'm VB6, and I think the file handling is somewhat different in VB.Net.
Jul 27 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.