Solved

set an event on file creation

Posted on 1999-01-11
10
163 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now