Link to home
Start Free TrialLog in
Avatar of gwosgood
gwosgoodFlag for United States of America

asked on

Watching a folder for file population

Hello all, I have a rather tricky VB problem I have not been able to solve so far.
I need to write a function that will "watch" an error folder for file population.  If a file jumps into the error folder, I need to perform a series of operations (i.e. copy to another directory, rename, strip extension, ect. ) on the said file and delete it from the error folder in the end.  The problem with this is the file that appears in the error folder is not always the same name.  depending on the nature of the error, a range of different files can potentially appear.  In addition, it is possible for more than one file to populate in this location at a time, it is not uncommon to have seven or more such files appear at once.  I need some sort of way to constantly scan the folder to detect for errors even though my operations will only handle one at a time.

I tried doing this with a simple timer control but am having difficutly opening a folder and scanning for files without having the exact name.  Any suggestions?
Avatar of vinnyd79
vinnyd79

Maybe this example can help:

http://www.thescarms.com/vbasic/FolderSpy.asp
That looks pretty cool.  I think I'll download that for future use.  Thanks!
ASKER CERTIFIED SOLUTION
Avatar of unknown_routine
unknown_routine
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It's also alot easier now in VB.Net seeing that MS now sends a canned filewatch control along with.
Avatar of gwosgood

ASKER

Comment for "unknown_routine"  your solution appears to be very handy.  My only question is how to use.  Would I just tie it into a timer routine and check for files once every X seconds?
Exactly,

As far as your timer interval is bigger that 100 (1 tenth of a second)

it is healthy( usage of CPU is negligible).




Regards.