FileSystemWatcher not firing changed event

T

Tony

I have setup a FileSystemWatcher to fire an event when the specified file is
modified.
But the event never fires for some reason and the file is being modified.

I have pasted the setup code below. I must be doing something wrong (I have
verified the file names and path as being correct).

Tony

m_oFileSystemWatcher = new
FileSystemWatcher();
m_oFileSystemWatcher.NotifyFilter =
NotifyFilters.LastWrite;
m_oFileSystemWatcher.Path =
Path.GetDirectoryName(sLocalFilename);
m_oFileSystemWatcher.Filter =
Path.GetFileName(sLocalFilename);
m_oFileSystemWatcher.Changed += new
FileSystemEventHandler(OnFileSystemWatcher_Changed);
m_oFileSystemWatcher.EnableRaisingEvents = true;


private void OnFileSystemWatcher_Changed(object sender,
FileSystemEventArgs e)
{
m_bFileModified = true;
}
 
G

Guest

Perhaps the path is the problem. Are you specifying a "fully rooted" path in
sLocalFileName, as in "driveletter:\blah-blah"? If not, you may not be
setting the watcher on the directory you think you are.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top