473,399 Members | 2,774 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,399 software developers and data experts.

Help - Continuous file reading!

Hi everybody,

Is it possible to do that in VB.NET: I have a text file that is filled
with new lines of text every n seconds. This text file get very massive.

I want to have my program to monitor this text file and to be able to
read only the new added line when it detect that a new line has been added.

I don't want to read the whole file every time, this would be high time
consuming.

Any idea? Thanks you very much!

Marty
Nov 21 '05 #1
4 2573
* Marty <re***@to.forum> scripsit:
Is it possible to do that in VB.NET: I have a text file that is
filled with new lines of text every n seconds. This text file get
very massive.
I want to have my program to monitor this text file and to be able to
read only the new added line when it detect that a new line has been
added.
I don't want to read the whole file every time, this would be high
time consuming.


Check the file size every n seconds and store the previous file size.
Then you can use the 'FileStream''s 'Seek' method or 'Position' property
to read data beginning at the position where the file ended the last
time you read it.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #2
Thanks Herfried,

It work very well.

I have another question, how can I be sure that by reading the file, I
don't interrupt the other process who want to add a text line to it?

This is my reader object settings:
Dim fs As New FileStream(strFilePath, FileMode.Open, FileAccess.Read)
Dim ioFileIN As StreamReader = New StreamReader(fs)

Is there anything else that I can set to have my ioFileIN not holding
the file while reading?

Thanks

Marty

Herfried K. Wagner [MVP] wrote:
* Marty <re***@to.forum> scripsit:
Is it possible to do that in VB.NET: I have a text file that is
filled with new lines of text every n seconds. This text file get
very massive.
I want to have my program to monitor this text file and to be able to
read only the new added line when it detect that a new line has been
added.
I don't want to read the whole file every time, this would be high
time consuming.

Check the file size every n seconds and store the previous file size.
Then you can use the 'FileStream''s 'Seek' method or 'Position' property
to read data beginning at the position where the file ended the last
time you read it.

Nov 21 '05 #3
* Marty <re***@to.forum> scripsit:
I have another question, how can I be sure that by reading the file, I
don't interrupt the other process who want to add a text line to it?
This is my reader object settings:
Dim fs As New FileStream(strFilePath, FileMode.Open, FileAccess.Read)


'FileStream' provides a ctor that accepts a 'FileShare':

\\\
Public Sub New( _
ByVal path As String, _
ByVal mode As FileMode, _
ByVal access As FileAccess, _
ByVal share As FileShare, _
ByVal bufferSize As Integer, _
ByVal useAsync As Boolean _
)
///

Set 'Share' to 'FileShare.ReadWrite'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #4
Marvelous! thanks you. :)
Herfried K. Wagner [MVP] wrote:
* Marty <re***@to.forum> scripsit:
I have another question, how can I be sure that by reading the file, I
don't interrupt the other process who want to add a text line to it?
This is my reader object settings:
Dim fs As New FileStream(strFilePath, FileMode.Open, FileAccess.Read)

'FileStream' provides a ctor that accepts a 'FileShare':

\\\
Public Sub New( _
ByVal path As String, _
ByVal mode As FileMode, _
ByVal access As FileAccess, _
ByVal share As FileShare, _
ByVal bufferSize As Integer, _
ByVal useAsync As Boolean _
)
///

Set 'Share' to 'FileShare.ReadWrite'.

Nov 21 '05 #5

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

Similar topics

4
by: Marty | last post by:
Hi everybody, Is it possible to do that in VB.NET: I have a text file that is filled with new lines of text every n seconds. This text file get very massive. I want to have my program to...
13
by: Jeff Pritchard | last post by:
I have an MDB that contains a single table. Checkweigher data is being continuously written to this MDB from a dedicated workstation over a network into the MDB on the server at the rate of about...
2
by: Mike | last post by:
Hi I have been tasked with converting my pulp and paper mills weekly projected and actual contractor hrs excel spreadsheet into a an Access 97 database. So far my design has been to use a...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
2
by: Lyn | last post by:
Hi, I am struggling to display photographs in a list format. Any help will be greatly appreciated. Originally I had attempted to store photographs as embedded OLE Objects, but had lots of...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
0
by: Jeremy Wallace | last post by:
Folks, Here's a write-up I did for our developer wiki. I don't know if the whole rest of the world has already figured out how to do this, but I hadn't ever seen it implemented, and had spent a...
2
by: Phil Stanton | last post by:
Is it possible to display different images on continuous forms. The path to the picture is held in a table, and the photos are held in another folder. I am trying to avoid using OLE Object due to...
1
by: blueheelers | last post by:
I have been researching for several hours on the best way to display images in continous forms in Access 2003. For example, I want to display employee name, email, phone, and picture for each...
7
by: capnwhit | last post by:
Hello all, The program below has a bug... The program is supposed to convert a string to a continuous hex dump and back to a string. The output should be as follows: abcd 61626364 abcd
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.