473,326 Members | 2,061 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,326 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 1336

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?
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.