Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

set an event on file creation

How do I set an event to start a procedure when a file appears in a directory? May I use wildcards on that filename?
0
marcelofr
Asked:
marcelofr
  • 4
  • 3
  • 2
  • +1
1 Solution
 
jjbyersCommented:
You'll have to have a timer that fires a method that first looks for the file and then have this method fire the event.
0
 
jjbyersCommented:
Sorry, Yes you can use wildcards witht the dir method.
0
 
marcelofrAuthor Commented:
I knew this... but there's no other way to do it?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
marcelofrAuthor Commented:
I knew this... but there's no other way to do it?
0
 
jjbyersCommented:
Not that I know of. Sorry
0
 
spennerCommented:
Try looking at this code.  It watches a directory for any change.
http://www.mvps.org/vbnet/code/fileapi/watchedfolder.htm
0
 
eduncCommented:
if you are waiting for a file to appear within like 10 seconds  or less then i would use this code:

do until dir(fname)
doEvents    'so the computer doesn't freeze up and go slow
loop
call whatever

fname could be like "blank.txt" or "*.exe" that has wildcards.

or if you're trying to just monitor if a file is there over a long period of time, i would make a timer w/ an interval of about 5 sec. or whatever you think.  put this code in it:

if dir(fname) then call whatever
0
 
marcelofrAuthor Commented:
I think there should be some event for a new file in an event driven language on an event driven OS, I DON'T like active loops: they're too expensive to the cpu. I'm look at spenner suggestion which is closer to my needs, I hope...
0
 
marcelofrAuthor Commented:
spenner: I like your suggestion. Post an answer ans I'll give you the points.
0
 
spennerCommented:
OK - If I find some better code I'll post it - but I've looked and the stuff I posted was the best I could find
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now