473,399 Members | 3,832 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,399 software developers and data experts.

deleting an filewatcher object that was created in code

Hi

I create a number of filewatchers in my code. I have a need to delete some
of the file watchers, but can not figure out how to do this without stopping
the application and restarting.

To create the filewatcher I have this code.... There doesn't seem to be a
name or index for the filewatch so how do I delete one?

Dim watcher As New FileSystemWatcher()
watcher.Path = strPath
watcher.NotifyFilter = (NotifyFilters.LastAccess Or
NotifyFilters.LastWrite Or NotifyFilters.FileName Or
NotifyFilters.DirectoryName)
watcher.Filter = strFilter

Jun 27 '08 #1
3 1076
Aussie,

Simple answer, you cannot change an application without stopping it.

After building you are installing in fact a new application.

Cor

"Aussie Rules" <au****@nospam.comschreef in bericht
news:O9**************@TK2MSFTNGP02.phx.gbl...
Hi

I create a number of filewatchers in my code. I have a need to delete some
of the file watchers, but can not figure out how to do this without
stopping the application and restarting.

To create the filewatcher I have this code.... There doesn't seem to be a
name or index for the filewatch so how do I delete one?

Dim watcher As New FileSystemWatcher()
watcher.Path = strPath
watcher.NotifyFilter = (NotifyFilters.LastAccess Or
NotifyFilters.LastWrite Or NotifyFilters.FileName Or
NotifyFilters.DirectoryName)
watcher.Filter = strFilter
Jun 27 '08 #2
On Fri, 6 Jun 2008 21:13:52 +1000, "Aussie Rules" <au****@nospam.com>
wrote:
>Hi

I create a number of filewatchers in my code. I have a need to delete some
of the file watchers, but can not figure out how to do this without stopping
the application and restarting.

To create the filewatcher I have this code.... There doesn't seem to be a
name or index for the filewatch so how do I delete one?

Dim watcher As New FileSystemWatcher()
watcher.Path = strPath
watcher.NotifyFilter = (NotifyFilters.LastAccess Or
NotifyFilters.LastWrite Or NotifyFilters.FileName Or
NotifyFilters.DirectoryName)
watcher.Filter = strFilter
You would need to remember the reference to the object, probably in a
form property, and then probably call its Dispose method to make it
stop watching.
Jun 27 '08 #3
Aussie Rules wrote:
Hi

I create a number of filewatchers in my code. I have a need to delete
some of the file watchers, but can not figure out how to do this
without stopping the application and restarting.

To create the filewatcher I have this code.... There doesn't seem to
be a name or index for the filewatch so how do I delete one?

Dim watcher As New FileSystemWatcher()
watcher.Path = strPath
watcher.NotifyFilter = (NotifyFilters.LastAccess Or
NotifyFilters.LastWrite Or NotifyFilters.FileName Or
NotifyFilters.DirectoryName)
watcher.Filter = strFilter
You should certainly be hanging on to the object; in the case above, the
variable watcher should not be a local variable.

You can disable file watchers (EnableRaisingEvents = False), so there is really
no need to dispose of them, but you need the variable if you want to be able to
control them or dispose of them.

Jun 27 '08 #4

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

Similar topics

4
by: Ron King Jr | last post by:
I have a small problem with my windows service. The first time I start the service everything works the way it's suppose to, but randomly the service fails. The jist of the service is to use the...
1
by: PeterNZ | last post by:
Hi all, I developped an C# app which is using FileSystemWatcher. If a file is created in a specific folder, it opens the file and does some processing. This functionality works without...
6
by: Troy Murphy | last post by:
The help file for Visual Studio .NET version 1 had a Walkthru for installing a Windows Service that would monitor a folder. Version 1.1 does not seem to have that example anymore. Could someone...
4
by: al havrilla | last post by:
hi all what does the phrase: "scalar deleting destructor" mean? i'm getting this in a debug error message using c++ 7.1 thanks Al
3
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...
2
by: Roger Twomey | last post by:
I am working on a filewatcher application. The premis is: User uploads an xml file onto the web server the filewatcher app sees the xml file filewatcher app reads the file and inserts...
1
by: ba.hons | last post by:
Hello, I have a file watcher object which i use to check a directory for XML files. When an XML file is placed in the directory i check the filename, to make sure it for me, then parse the...
0
by: tshad | last post by:
I have a filewatcher program that is working syncronously (which is how I want it to work). But my program will handle whatever files are in the folder at the time it runs. So when I drop 15...
7
by: tshad | last post by:
What exactly is FileWatcher doing? When you drop 100 files in a folder it is watching, it normally will fire of the event 100 times. In my case, I do all my processing on the first event so I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.