Solved

set an event on file creation

Posted on 1999-01-11
10
174 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
  • 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 189
Excel VBA combine two working workbooks 8 54
Excel Automation VBA 19 70
Automatic Email Reminder 4 37
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.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

770 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