473,549 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2585
* 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(strF ilePath, 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(strF ilePath, 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.Read Write'.

--
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(strF ilePath, 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.Read Write'.

Nov 21 '05 #5

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

Similar topics

4
1500
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 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...
13
3090
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 120 records a minute. This may increase in the future to about 200. The records are not large. We have other workstations that run sessions on...
2
2128
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 form with a button for each to day navigate the recordset of a single table using .findfirst and .nomatch and I am worried about performance as I'm...
4
3158
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. Tables: (abbreviated) TblDivision DivisionID
2
1813
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 trouble. I eventually abandoned this on advice from this group that this format was not reliable, not to mention that it bloated the database. Since...
9
6747
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 second combo to change depending on what values the user selects in the first box, it's just that every time the user changes the first combobox, the...
0
2916
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 lot of time trying to figure it out, over the years. It finally dawned on me a couple of weeks ago how to do this. A couple of notes: 1) This is...
2
2528
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 file size problems and problems of making sure the database is up-to-date. Thanks Phil
1
10887
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 record in the recordset. I can have the pictures converted to any usable format, use OLE or linking, whatever needs to be done. So far, the 3...
7
5676
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
7541
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7464
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7734
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7826
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5385
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5107
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3493
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1960
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
781
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.