473,404 Members | 2,114 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,404 software developers and data experts.

FileWatcher check on startup?

Is there some way to have the fileWatcher to initially check the folder to
see if there is anything in it (based on the filters)?

If I reboot the machine, for example, and it starts up the service - I would
like it to look at the folder initially. The reason being that I may bring
the system down and at that point the files may be written to the target
directory. When I bring it back up again and the service starts, it won't
see that the files were added to the folder while it was down and will never
see those files.

Thanks,

Tom
Feb 1 '08 #1
3 2134
"tshad" <ts***@dslextreme.comwrote in message
news:um**************@TK2MSFTNGP05.phx.gbl...
Is there some way to have the fileWatcher to initially check the folder to
see if there is anything in it (based on the filters)?

If I reboot the machine, for example, and it starts up the service - I
would like it to look at the folder initially. The reason being that I
may bring the system down and at that point the files may be written to
the target directory. When I bring it back up again and the service
starts, it won't see that the files were added to the folder while it was
down and will never see those files.

Thanks,

Tom
Immediately after setting up the file watcher, do a manual check via
File.Exists() or Directory.GetFiles() and handle anything you find at that
point.

Mike.
Feb 1 '08 #2
Tom,

No, there isn't, but that doesn't mean that you can't scan the folder
yourself before you start the file watcher. Because you might run into a
situation where a file might be changed while the file watcher operates, you
might want to block the file watchers events from executing before you are
done scanning the directory initially.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"tshad" <ts***@dslextreme.comwrote in message
news:um**************@TK2MSFTNGP05.phx.gbl...
Is there some way to have the fileWatcher to initially check the folder to
see if there is anything in it (based on the filters)?

If I reboot the machine, for example, and it starts up the service - I
would like it to look at the folder initially. The reason being that I
may bring the system down and at that point the files may be written to
the target directory. When I bring it back up again and the service
starts, it won't see that the files were added to the folder while it was
down and will never see those files.

Thanks,

Tom
Feb 1 '08 #3
"Michael D. Ober" <obermd.@.alum.mit.edu.nospam.wrote in message
news:13*************@corp.supernews.com...
"tshad" <ts***@dslextreme.comwrote in message
news:um**************@TK2MSFTNGP05.phx.gbl...
>Is there some way to have the fileWatcher to initially check the folder
to see if there is anything in it (based on the filters)?

If I reboot the machine, for example, and it starts up the service - I
would like it to look at the folder initially. The reason being that I
may bring the system down and at that point the files may be written to
the target directory. When I bring it back up again and the service
starts, it won't see that the files were added to the folder while it was
down and will never see those files.

Thanks,

Tom
Immediately after setting up the file watcher, do a manual check via
File.Exists() or Directory.GetFiles() and handle anything you find at that
point.
I did Directory.GetFiles() and it worked fine.

Unfortunately, it doesn't seem to allow multiple filters, so I just did it 3
times as I needed to see files that started with "IN*", "GL*" and "TX*"
only.

Thanks,

Tom
>
Mike.


Feb 1 '08 #4

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

Similar topics

0
by: Lloyd Sheen | last post by:
Ok here is problem. Steps: 1. Get filename from Directory.GetFiles collection 2. Store in SQL Server the name as string 3. Another program implements FileWatcher 4. Change the file who's...
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...
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...
0
by: adam_scheich | last post by:
When creating a file in excel and saving it to a directory that is being watched by filewatcher using Save As, the filewatcher created event doesn't fire. It works fine for text files, but for...
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...
3
by: ba.hons | last post by:
Hello All. I have a filewatcher object which looks at a shared folder and when a new XML file is placed in this folder the on create method calls a method which reads the XML file and based on...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
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...

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.