473,238 Members | 1,800 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,238 software developers and data experts.

Unable to detect a file change with FileSystemWatcher

Hi,

I have some problems to detect when a file is changed by another application
(the file is changed several times by the application). Sometimes, it is
correctly detected, sometimes not. I maybe expect an access problem. Can it
be? And how to solve it? Below is a part of my code (written in C#). Is there
anybody who can help me?

....
FileSystemWatcher watcher = new FileSystemWatcher();
watcher.Path = "C:\\TEMP;
watcher.NotifyFilter = NotifyFilters.LastWrite ;
watcher.Filter = "file1.ini";
mszStatus = "Start";
watcher.Changed += new FileSystemEventHandler(OnChanged);
watcher.EnableRaisingEvents = true;
method.mfStart(); // This will start the external program

// Wait so that the method is completed.
while (String.Compare(mszStatus,"Stop") != 0)
{
System.Threading.Thread.Sleep(10);
}

.....

// Define the event handlers.
private void OnChanged(object source, FileSystemEventArgs e)
{
.... // Look in the file for a specific string
if (....) // If string = finished
{
mszStatus = "Stop";
}
}

Jul 22 '05 #1
0 1333

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

Similar topics

9
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit...
4
by: Doug R | last post by:
Hello, I could use a little help from you Gurus out there. I have an aplication that watches a directory and detects when a PGP encrypted file lands in the directory and starts a process that...
3
by: Vinny | last post by:
Hey all. I'm now attributing the problem I'm having to something incredibly simple, to which I must be overlooking. I created a Windows Service application that listens for files. The file paths...
12
by: Anders Eriksson | last post by:
Hello! I'm trying to create a program that will watch a directory and when a file is created print that file. I have used FileSystemWatcher for watching the directory and I get an created event....
0
by: Cédric | last post by:
Hi, I have some problems to detect when a file is changed by another application (the file is changed several times by the application). Sometimes, it is correctly detected, sometimes not. I...
3
by: Kenneth H. Brannigan | last post by:
Hello, I have a FileSystemWatcher looking at a particular directory. When I copy a large file (750 MB) to this directory I receive multiple Change events. I am fine with this but when I call...
4
by: intrepid_dw | last post by:
All: I have a .NET 1.1 C#-based WinForms application that, as part of its normal operation, creates and updates an XML-based log file. I expose a method from a class to retrieve the text of the...
0
by: deerchao | last post by:
I'm using FileSystemWatcher to watch the new file creation. When there is one, I want to open it and read it's content. But, by the time when I got the message from FileSystemWatcher the file may...
6
by: Andy B | last post by:
What would i use to look for changes in a file every minute?
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.