Solved

set an event on file creation

Posted on 1999-01-11
10
185 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
Technology Partners: 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!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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 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…

756 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