473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Read text file which is still updated

Hi

I'm new in VB.NET.
I wrote an application which opens a text file and read it all lines
untill the EOF
this file is open for read only and for sharing asllowed.
every 5 seconds another applications write another line to this file
at the end and I'm trying to read those new lines from my
applications. the problem is that the EOF function returns TRUE even
though a new lines added to this file.
what can I do?

I open the file using the function:
FileOpen(1, File, OpenMode.Input, OpenAccess.Read, OpenShare.Shared)

I read line using the function:
Linet = LineInput(1)

I check EOF with the function:
EOF(1)

Do I need to use diffrent functions for open and read that file?

Thanks for the help...

Feb 19 '07 #1
3 4184

Yaniv wrote:
Hi

I'm new in VB.NET.
I wrote an application which opens a text file and read it all lines
untill the EOF
this file is open for read only and for sharing asllowed.
every 5 seconds another applications write another line to this file
at the end and I'm trying to read those new lines from my
applications. the problem is that the EOF function returns TRUE even
though a new lines added to this file.
what can I do?

I open the file using the function:
FileOpen(1, File, OpenMode.Input, OpenAccess.Read, OpenShare.Shared)

I read line using the function:
Linet = LineInput(1)

I check EOF with the function:
EOF(1)

Do I need to use diffrent functions for open and read that file?

Thanks for the help...
Maybe close the file after reading, then reopen it after 5 seconds.
It's simple, but that would be a lot of file opening and closing...
Instead, maybe have a bookmark variable keep track of the number of
lines you have read. Then, after 5 seconds, seek back to the bookmark
(there's a procedure that lets you set the position in the file
stream) and start reading again. You'd have to change your reading
loop a bit.

Feb 19 '07 #2
Thanks.

Could you please tell me which function does that ?
Is there a code sample anywhere in the internet for this?

lo*********@gmail.com כתב:
Yaniv wrote:
Hi

I'm new in VB.NET.
I wrote an application which opens a text file and read it all lines
untill the EOF
this file is open for read only and for sharing asllowed.
every 5 seconds another applications write another line to this file
at the end and I'm trying to read those new lines from my
applications. the problem is that the EOF function returns TRUE even
though a new lines added to this file.
what can I do?

I open the file using the function:
FileOpen(1, File, OpenMode.Input, OpenAccess.Read, OpenShare.Shared)

I read line using the function:
Linet = LineInput(1)

I check EOF with the function:
EOF(1)

Do I need to use diffrent functions for open and read that file?

Thanks for the help...

Maybe close the file after reading, then reopen it after 5 seconds.
It's simple, but that would be a lot of file opening and closing...
Instead, maybe have a bookmark variable keep track of the number of
lines you have read. Then, after 5 seconds, seek back to the bookmark
(there's a procedure that lets you set the position in the file
stream) and start reading again. You'd have to change your reading
loop a bit.
Feb 19 '07 #3
Yaniv wrote:
Hi

I'm new in VB.NET.
I wrote an application which opens a text file and read it all lines
untill the EOF
this file is open for read only and for sharing asllowed.
every 5 seconds another applications write another line to this file
at the end and I'm trying to read those new lines from my
applications. the problem is that the EOF function returns TRUE even
though a new lines added to this file.
what can I do?

I open the file using the function:
FileOpen(1, File, OpenMode.Input, OpenAccess.Read, OpenShare.Shared)

I read line using the function:
Linet = LineInput(1)

I check EOF with the function:
EOF(1)

Do I need to use diffrent functions for open and read that file?

Thanks for the help...
I believe that you have to close the file and open it again to get a
file handle with the new file size.

If you only want to read the added lines, you can periodically check for
a change in the file size. When it changes you can open the file as a
binary file, seek to the previos file end and read the remaining bytes.
Then you can use the Encoding.UTF8 object to decode the bytes into a string.

However, reading a file that is being written to is a bit shaky. If
possible, perhaps you should consider an alternative way of storing the
information, like for example a database table. A database is better
equipped to handle simultaneous reading and writing of data than the
file system is.

--
Göran Andersson
_____
http://www.guffa.com
Feb 19 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: John | last post by:
I just learned that it is possible to grab a text file from another site and display the data on my own site, however when I display the data it does not format it correctly. Can anyone please...
12
by: Steven T. Hatton | last post by:
I know of a least one person who believes std::ifstream::read() and std::ofstream::write() are "mistakes". They seem to do the job I want done. What's wrong with them. This is the code I...
5
by: Martin Svensson | last post by:
Hello! I need some help/recommendations on how to do the following. I have a program that writes an IP address two control numbers and a date to file, on one line. It's a basic text file and it...
35
by: RyanS09 | last post by:
Hello- I am trying to write a snippet which will open a text file with an integer on each line. I would like to read the last integer in the file. I am currently using: file = fopen("f.txt",...
8
by: kepioo | last post by:
I currently have an xml input file containing lots of data. My objectiv is to write a script that reports in another xml file only the data I am interested in. Doing this is really easy using SAX....
3
gsgurdeep
by: gsgurdeep | last post by:
Good Morning I want to display text of a notepad file on a html page. File is randomly updated any time by an employ. after update html page should be updated autometically. tell me the solution.
1
by: Sagar | last post by:
I want to write a program, that reads and logs the windows events that happened in a particular folder once every minute, 1. A file was created in the folder. which user created ? 2. A file was...
2
by: Eric | last post by:
Hi, There is a textbox which contains some text. The purpose is to update the text manually into the textbox and send (update) the updated text to the database. My problem is that when i...
4
by: Keith G Hicks | last post by:
I'm trying to read a text file and alter the contents of specific lines in the file. I know how to use streamreader to read each line of a file. I'm doing that already to get the data into a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.