Solved

set an event on file creation

Posted on 1999-01-11
10
193 Views
Last Modified: 2010-05-03
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
Comment
Question by:marcelofr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 3

Expert Comment

by:jjbyers
ID: 1455315
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
 
LVL 3

Expert Comment

by:jjbyers
ID: 1455316
Sorry, Yes you can use wildcards witht the dir method.
0
 
LVL 3

Author Comment

by:marcelofr
ID: 1455317
I knew this... but there's no other way to do it?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 3

Author Comment

by:marcelofr
ID: 1455318
I knew this... but there's no other way to do it?
0
 
LVL 3

Expert Comment

by:jjbyers
ID: 1455319
Not that I know of. Sorry
0
 
LVL 2

Expert Comment

by:spenner
ID: 1455320
Try looking at this code.  It watches a directory for any change.
http://www.mvps.org/vbnet/code/fileapi/watchedfolder.htm
0
 

Expert Comment

by:edunc
ID: 1455321
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
 
LVL 3

Author Comment

by:marcelofr
ID: 1455322
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
 
LVL 3

Author Comment

by:marcelofr
ID: 1455323
spenner: I like your suggestion. Post an answer ans I'll give you the points.
0
 
LVL 2

Accepted Solution

by:
spenner earned 50 total points
ID: 1455324
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question