473,756 Members | 4,046 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to active the FileSystemWatch er object????

Hi all,
I had made a program to watching files in my directory. I had used a
instance of FileSystemWatch er to do my work.And I had add some events of the
FileSystemWatch er , for example onChange, onRename and so on.
And I had made this program as a windows service.As I know, if I delete a
file from my directory, this behavior will active this program and do
something what I want to do. But after I install this program as a windows
service and doing some behavior in the directory which I had set as the
property of the instance of FileSystemWatch er, this program will not do my
work for me.How can I solve it?
Acturaly, after I installed this program as the windows service and start
the debug in vs.net 2003 , it won't active the break point where I had set
the break point at the onChanged event. And I had added the handler of this
event.
Nov 16 '05 #1
2 2229
EnableRaisingEv ents property. The majority of the users of this API in
production
scenarios want to configure the object once, and then enable/disable the event
notifications as needed for performance reasons. I remember some mail about
specific scenarios when I was working on the .NET QuickStarts, but I couldn't
tell
you more precisely why they changed the API to have this property false by
default.
--
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers
"Jet Leung" <xi**@163.net > wrote in message
news:e9******** *****@tk2msftng p13.phx.gbl...
Hi all,
I had made a program to watching files in my directory. I had used a
instance of FileSystemWatch er to do my work.And I had add some events of the
FileSystemWatch er , for example onChange, onRename and so on.
And I had made this program as a windows service.As I know, if I delete a
file from my directory, this behavior will active this program and do
something what I want to do. But after I install this program as a windows
service and doing some behavior in the directory which I had set as the
property of the instance of FileSystemWatch er, this program will not do my
work for me.How can I solve it?
Acturaly, after I installed this program as the windows service and start
the debug in vs.net 2003 , it won't active the break point where I had set
the break point at the onChanged event. And I had added the handler of this
event.

Nov 16 '05 #2
Hi jet,

Here is some code that is working in a similar environment.
Take a look that all this service does depend of the FileSystemWatch er
events.
Note:
This may not compile as is as I removed lot of code !!

HTH,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


public class DismexOrderDisp atcher : System.ServiceP rocess.ServiceB ase
{

protected override void OnStart(string[] args)
{
// This trigger the static constructor of the DataProvider class
DataProvider.Ca llme();
}
}

public class DataProvider
{

static FileSystemWatch er watcher=null;
static public void callme(){}
//This function "watch" a directory waiting for orders to arrive
public static void WatchOrdersFold er()
{
try
{
if ( watcher!=null) return;
watcher = new FileSystemWatch er();

watcher.Path = Config.ImportSt orageFolder;
watcher.NotifyF ilter = NotifyFilters.F ileName
|NotifyFilters. CreationTime;
watcher.Filter = "*.flag";

// Add event handlers.
watcher.Created += new FileSystemEvent Handler( AddedOrderFile) ;
watcher.EnableR aisingEvents = true;
}
catch(Exception ex)
{
Logger.CreateLo g( "Error in WatchOrdersFold er e.m:" + ex.Message + "
e.ST:" + ex.StackTrace, System.Diagnost ics.EventLogEnt ryType.Error );
}

}

static DataProvider()
{
try
{

//Set the FileFolderWatch er in the directory where the network deamon
put the files
WatchOrdersFold er();
}
catch( Exception e)
{
}

}

}

"Jet Leung" <xi**@163.net > wrote in message
news:e9******** *****@tk2msftng p13.phx.gbl...
Hi all,
I had made a program to watching files in my directory. I had used a
instance of FileSystemWatch er to do my work.And I had add some events of the FileSystemWatch er , for example onChange, onRename and so on.
And I had made this program as a windows service.As I know, if I delete a
file from my directory, this behavior will active this program and do
something what I want to do. But after I install this program as a windows
service and doing some behavior in the directory which I had set as the
property of the instance of FileSystemWatch er, this program will not do my
work for me.How can I solve it?
Acturaly, after I installed this program as the windows service and start
the debug in vs.net 2003 , it won't active the break point where I had set
the break point at the onChanged event. And I had added the handler of this event.

Nov 16 '05 #3

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

Similar topics

1
3332
by: Troy Murphy | last post by:
How do I prevent the FileSystemWatcher event to keep firing while the file is being created? When copying a file to the watched folder, the event fires a dozen or more times! Also, the documentation states that if more than one file is copied to the folder at the same time, a cache will queue them up for processing, but when I drop 3 files into this folder, only the 1st (sometimes the first two) cause the event to fire. Thanks, Troy
7
4122
by: Allen Anderson | last post by:
I'm trying to figure out a way to catch when a file has been written to a directory. I currently have it where I can catch when the file begins writing, but this isn't helpful as I need to know when its done. Does anyone know the right combination of flags to use to catch when the file has been written and closed? (here is my current code). // member variable FileSystemWatcher watcher = new FileSystemWatcher();
13
9174
by: David | last post by:
I have been working on trying to write a directory watcher service. One of the requirments is that it be able to watch multiple directories, not sub directories of one parent directory, but just multiple directories. I have hit a snag and don't know how to get around it. Basically I read in a list of directories from the app.config and stuff them into an array, so that I have something like this: sDirsToWatch = "C:\Temp"
1
4621
by: John Lee | last post by:
Hi, I developed a filewatcher service to monitor file creation on a network drive - 90% time it works fine and from time to time I found out that the newly created file on that network drive does not trigger the event - all I have to do is to restart the service. I kind of suspect the reason is when the target matchine where monitored drive is on gets rebooted, the filesystemwatcher lost its "monioring" capability, is that true? if...
20
4494
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my Global.asax and everything works fine.I have found FileSystemWatcher class not very reliable and sometimes it behavies unexpectedly.I'm afriad that...
1
2295
by: PadovaBoy | last post by:
Hi! I try to develop a simple system for monitoring a sub directory of a web site and remake an xml file every time a sub-dir change it's name. I don't wont to use a window.service because, i want to use the same system in many web-site. I have just write some line of code...but i have a problem: when i change the name of a file..i fire-up the Application_end events .... why? how i can meange the event of the filesystemwatcher?
7
4557
by: Frank | last post by:
Hi, I am using FileSystemWatcher to track the change in a text file. Whenever I run the program I get 99% CPU utilization. The code doesn't do anything just sits and waits in a while loop until the event is fired. Any ideas? Thanks Frank
1
2364
by: teslar91 | last post by:
I've been learning VB.NET for the past few weeks. One of the problems I've run into is difficulties updating controls in events from certain components, such as the FileSystemWatcher, that raise their events in different threads. I found plenty of examples on the Web of how to "detangle" the threads, using Delegate functions, .InvokeRequired, and .Invoke. But all of these examples demonstrated how to do it on a single form. I wanted...
5
5604
by: =?Utf-8?B?Sm9obiBT?= | last post by:
I am trying to find out if there is a way to tell if there is already a filesystemwatcher (created by a webservice) monitoring a folder. I have a webservice that creates a filesystemwatcher, monitors a folder and then returns the contents of the new/changed files. However, if the client app loses connection to the webservice without closing the filewatcher, and then reconnects (and thus creates a new watcher), I believe I end up with...
0
9255
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10014
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9844
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9819
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8688
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.