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;
}

RE: FileSystemWatcher not firing changed event by DavidWRogers

DavidWRogers
Mon Jan 03 12:49:06 CST 2005

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

"Tony" wrote:

> 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;
> }
>
>
>

Re: FileSystemWatcher not firing changed event by Tony

Tony
Tue Jan 04 23:36:38 CST 2005

Yes, it is a full path name including drive letter.

Tony

"David W. Rogers" <DavidWRogers@discussions.microsoft.com> wrote in message
news:4174B57C-E2E4-4D61-AF7E-0861A982983D@microsoft.com...
> 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
>
> "Tony" wrote:
>
>> 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;
>> }
>>
>>
>>