I've got an application that I'm modifying and the client needs it to
watch a particular file and then do some stuff when that file gets
modified. For example, let's say the file is C:\Test.dat and that it
looks like this...
AcctNum, 500
SomeValue, 4500
Periodically there is another program that changes the Test.dat file
values. The application I'm modifying needs to detect that the Test.dat
file has been modified, read it and then do some stuff with the values.
This isn't supder difficult. I can just place a timer in the
application that checks the File.GetLastWriteTime method for Test.dat
and then acts appropriately. However, that seems kind of inefficient.
Is there an event or something that I can latch onto to accomplish the
same thing without having to constantly fire a timer off?
Thanks for any help.
Andrew Cooper 5 1172
On Jun 18, 5:48*pm, Andrew Cooper <kairoscreat...@gmail.comwrote:
I've got an application that I'm modifying and the client needs it to
watch a particular file and then do some stuff when that file gets
modified. *For example, let's say the file is C:\Test.dat and that it
looks like this...
AcctNum, 500
SomeValue, 4500
Periodically there is another program that changes the Test.dat file
values. *The application I'm modifying needs to detect that the Test.dat
file has been modified, read it and then do some stuff with the values.
* This isn't supder difficult. *I can just place a timer in the
application that checks the File.GetLastWriteTime method for Test.dat
and then acts appropriately. *However, that seems kind of inefficient.
Is there an event or something that I can latch onto to accomplish the
same thing without having to constantly fire a timer off?
Thanks for any help.
Andrew Cooper
Hi,
As i understand from your needs, you'd better think of FileSystemWatch
component in your toolbox, get more info here: http://msdn.microsoft.com/en-us/libr...emwatcher.aspx
Thanks,
Onur Güzel
Hoi, you could try the FileSystemWatcher class
( http://msdn.microsoft.com/fr-fr/libr...er(VS.80).aspx)
assulming you can't change how information is exchanged between these two
progs...
--
Patrice
"Andrew Cooper" <ka************@gmail.coma écrit dans le message de groupe
de discussion : e5**************@TK2MSFTNGP06.phx.gbl...
I've got an application that I'm modifying and the client needs it to
watch a particular file and then do some stuff when that file gets
modified. For example, let's say the file is C:\Test.dat and that it
looks like this...
AcctNum, 500
SomeValue, 4500
Periodically there is another program that changes the Test.dat file
values. The application I'm modifying needs to detect that the Test.dat
file has been modified, read it and then do some stuff with the values.
This isn't supder difficult. I can just place a timer in the application
that checks the File.GetLastWriteTime method for Test.dat and then acts
appropriately. However, that seems kind of inefficient. Is there an event
or something that I can latch onto to accomplish the same thing without
having to constantly fire a timer off?
Thanks for any help.
Andrew Cooper
Thanks folks!
I knew there had to be a way to do that without a timer.
FileSystemWatcher is exactly what I need.
Also, Patrice, unfortunately I can't change how these programs
communicate. The other program is proprietary and modifying this file
is the most it will do to help me out. I'd much rather use a socket
connection or something to communicate but... alas!
Andrew
Andrew Cooper wrote:
I've got an application that I'm modifying and the client needs it to
watch a particular file and then do some stuff when that file gets
modified. For example, let's say the file is C:\Test.dat and that it
looks like this...
AcctNum, 500
SomeValue, 4500
Periodically there is another program that changes the Test.dat file
values. The application I'm modifying needs to detect that the Test.dat
file has been modified, read it and then do some stuff with the values.
This isn't supder difficult. I can just place a timer in the
application that checks the File.GetLastWriteTime method for Test.dat
and then acts appropriately. However, that seems kind of inefficient.
Is there an event or something that I can latch onto to accomplish the
same thing without having to constantly fire a timer off?
Thanks for any help.
Andrew Cooper
FileSystemWatcher is very convenient but far from perfect. Some events will
lost espectially with lot of actions simultaneously. You will need you timer
to keep clean job.
"Andrew Cooper" wrote:
Thanks folks!
I knew there had to be a way to do that without a timer.
FileSystemWatcher is exactly what I need.
Also, Patrice, unfortunately I can't change how these programs
communicate. The other program is proprietary and modifying this file
is the most it will do to help me out. I'd much rather use a socket
connection or something to communicate but... alas!
Andrew
Andrew Cooper wrote:
I've got an application that I'm modifying and the client needs it to
watch a particular file and then do some stuff when that file gets
modified. For example, let's say the file is C:\Test.dat and that it
looks like this...
AcctNum, 500
SomeValue, 4500
Periodically there is another program that changes the Test.dat file
values. The application I'm modifying needs to detect that the Test.dat
file has been modified, read it and then do some stuff with the values.
This isn't supder difficult. I can just place a timer in the
application that checks the File.GetLastWriteTime method for Test.dat
and then acts appropriately. However, that seems kind of inefficient.
Is there an event or something that I can latch onto to accomplish the
same thing without having to constantly fire a timer off?
Thanks for any help.
Andrew Cooper
The system isn't really that busy. The file is only being change every
great once in a while so I doubt I'll run into problems with it changing
too fast and missing something. But I will keep it in mind if things
start behaving strangely.
Andrew
intiratr wrote:
FileSystemWatcher is very convenient but far from perfect. Some events will
lost espectially with lot of actions simultaneously. You will need you timer
to keep clean job. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Benjamin D. LeMasurier |
last post by:
Hey everyone,
Is there a way to "watch" a file for changes? I know I could poll the
file every few seconds and check to see if the buffer has changed but
is there a cleaner way?
thanks!
Ben
|
by: Christopher Harrison |
last post by:
I would like to, cleanly, watch a flat file for changes (updates and
the like). The file will be altered by another program... I found some
example code (which actually didn't compile) on Google,...
|
by: Ajay Pal Singh |
last post by:
Hi,
I am creating a web service, which needs to take some actions based on the
config file. I need a way to listen the changes as they occur in the config
file so that the service can take...
|
by: Luis Esteban Valencia Muñoz |
last post by:
Hi everyone,
I created a VB.NET application that looks at a folder
in my local system from which I can read the file, enter data into the
database and delete the file. I am using the filewatcher...
|
by: paul |
last post by:
Watching connections to your computer.
Can some one tell where to start.
I want to write some code to be alerted when
some one connect to my computer and browses/copies/changes
files or...
| |
by: John Dann |
last post by:
I need to watch a specific file that updates at irregular intervals
and raise an event when an update happens (ie file date/time stamp
changes). I had heard that there is a native method in .Net...
|
by: John Dann |
last post by:
I'm using the FileSystemWatcher with NotifyFilters.LastWrite set. This
works fine during the same day but fails to fire its event for changes
in the monitored file after midnight, ie into the next...
|
by: Gordon Airporte |
last post by:
I'm trying to find a way to take a file that another program has opened
and writes to periodically, open it simultaneously in Python, and
automatically update some of my objects in Python when the...
|
by: Zed A. Shaw |
last post by:
Hi Everyone,
Just putting out an announcement that I've released a new version of
Vellum numbered 0.16. This version should be ready for people to use
as not much of the internal structure has...
|
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,...
|
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...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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: 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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |