Click here to Skip to main content
13,139,034 members (54,719 online)
Rate this:
Please Sign up or sign in to vote.
Hi all,
i have a receiver windows application which receives stream from a port (Logical port) on which my clients is sending me some feed.
my receiver receives the feed and write it in to a text file.

I have an other application which reads the text file parse it and dump it in to mysql database.

if for some reasons if i have to stop (close) my application which dumps data in to database and restart it. after restarting the application i want to read the text file where i left it while reading it before.
i mean to say that if i have read 100 lines from text file out of 1000 and for some reasons i have to close my application.
now i start my application again and want to start from 101 line.

bellow is the text file format

"31/07/12 11:31:18","GOLD-OC12","","TRD","","",""
"31/07/12 11:31:18","GOLD-OC12","","ORD","49433","50","49485","50","",""
"31/07/12 11:31:18","GOLD-OC12","","TRD","","",""
"31/07/12 11:31:18","GOLD-OC12","","ORD","49435","50","49485","50","",""
"31/07/12 11:31:18","GOLDKILO-OC12","","TRD","","",""
"31/07/12 11:31:18","GOLDKILO-OC12","","ORD","49403","5","49454","5","",""
"31/07/12 11:31:18","GOLDKILO-OC12","","TRD","","",""
"31/07/12 11:31:18","GOLDKILO-OC12","","ORD","49405","5","49454","5","",""
"31/07/12 11:31:18","GO100OZ-OC12","","TRD","1622.5","1","5"
"31/07/12 11:31:18","GO100OZ-C12","","ORD","1622.4","50","1622.8","50","1622.5","1"
"31/07/12 11:31:18","GO100OZ-OC12","","TRD","1622.5","1","5"
"31/07/12 11:31:18","GO100OZ-C12","","ORD","1622.4","50","1622.8","50","1622.5","1"
Posted 11-Aug-12 2:28am
Updated 11-Aug-12 10:24am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


We are not sure how your application is working, but making some assumption i am giving you one solution.

1) each text file have single log entry
2) you have single text file having all data.
Note : even other solutions are possible if above assumptions are incorrect.

- You can check your database table records and go directly on that line and start reading. Let me know if you have problem with reading text file from particular position.

ex : you have 100 records in your database then read your text file from 101 and your application will again dump data in database.

hope it works for you, Let me know if you have any query.

-Amit Gajjar
Farhan Qureshi 16-Aug-12 3:42am
yes i have single text file and at the day end the size of text file is around 250 to 350 mb

and please help me with example of reading text file from particular position
@amitgajjar 16-Aug-12 4:12am
then proposed solution will work for you.
Farhan Qureshi 16-Aug-12 5:45am
but need example
reading text file from particular position.
@amitgajjar 16-Aug-12 6:47am
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

you mean to save last line no. some where and when application start retrieve that line no.,
read text file's lines on by one and nothing to do till counter reaches the line no. means if counter>= line_no then add entries in database

you can store Line-no three ways.
1. In database
2. In global application user-defined property (settings.designer.vb page)
3. In Registry key.

do not forget to increase line-no and update it's status in (database or global application user-defined property or registry key - any of source you used) when you have processed the line.

Happy Coding!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170915.1 | Last Updated 11 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100