-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: DotNetLearner
Message 1 in Discussion
Hello, I have a windows service to watch some folders on a server machine and
raising the events. I have created one object to watch one folder. But I need to take
the folder details from a config files about the folders to be "watched" for any file
creation,deletion. For this I am using an array of FileSystemWatch object, but it is
not working. Please check the following code and correct me where I am wrong. But same
application is working with one FileSystemWatch object and one Folder.
//Getting the folder paths from Config File, separated by semi-colon
strFolderPaths = ConfigurationSettings.AppSettings["Folders"];
//Assigning the paths separated by semi-col
string[] strFolderTemp = strFolderPaths.Split(';');
int intFolderCount = strFolderTemp.Length;
if (intFolderCount > 0)
{
//Creating an array of FileSystemWatcher objects to watch N folders
FileSystemWatcher[] objFile = new FileSystemWatcher[intFolderCount];
//Only Delete event has to be captured - all other event handling can be removed
for(int intCount=0;intCount < objFile.Length;intCount++)
{
objFile[intCount]= new FileSystemWatcher(strFolderTemp[intCount],"");
objFile[intCount].Created += new FileSystemEventHandler(this.FileCreated);
objFile[intCount].Renamed += new RenamedEventHandler(this.FileReNamed);
objFile[intCount].Deleted += new FileSystemEventHandler(this.FileDeleted);
objFile[intCount].EnableRaisingEvents = true;
}
}
Thanks in advance
Suhas
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]