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
Solved

Watching a folder for file population

Posted on 2004-08-17
6
318 Views
Last Modified: 2010-05-02
Hello all, I have a rather tricky VB problem I have not been able to solve so far.
I need to write a function that will "watch" an error folder for file population.  If a file jumps into the error folder, I need to perform a series of operations (i.e. copy to another directory, rename, strip extension, ect. ) on the said file and delete it from the error folder in the end.  The problem with this is the file that appears in the error folder is not always the same name.  depending on the nature of the error, a range of different files can potentially appear.  In addition, it is possible for more than one file to populate in this location at a time, it is not uncommon to have seven or more such files appear at once.  I need some sort of way to constantly scan the folder to detect for errors even though my operations will only handle one at a time.

I tried doing this with a simple timer control but am having difficutly opening a folder and scanning for files without having the exact name.  Any suggestions?
0
Comment
Question by:gwosgood
6 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 11822297
Maybe this example can help:

http://www.thescarms.com/vbasic/FolderSpy.asp
0
 
LVL 4

Expert Comment

by:Steve Sirica
ID: 11822816
That looks pretty cool.  I think I'll download that for future use.  Thanks!
0
 
LVL 15

Accepted Solution

by:
unknown_routine earned 500 total points
ID: 11822826
Hi


You can achieve this using FilesySystemObject


Add a reference to "microsoft scripting runtime"  to your project

then use this sample code:

Private Sub Form_Load()

    Dim fs As New FileSystemObject
   
    Dim fo As Folder
   
    Set fo = fs.GetFolder("C:\Myfloder")    '<===Change this to the specific folder name
   
    Dim Fi As File
   
    For Each Fi In fo.Files
   
         MsgBox " Name=" & Fi.Name & " " & vbCrLf & "Date created=" & Fi.DateCreated
   
    Next

End Sub



In the above code Fi(file object) has a lots ofother useful properties whcih you can use them.


More questions, please  Ask,


Regards.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 4

Expert Comment

by:Steve Sirica
ID: 11822889
It's also alot easier now in VB.Net seeing that MS now sends a canned filewatch control along with.
0
 
LVL 2

Author Comment

by:gwosgood
ID: 11823375
Comment for "unknown_routine"  your solution appears to be very handy.  My only question is how to use.  Would I just tie it into a timer routine and check for files once every X seconds?
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 11823443
Exactly,

As far as your timer interval is bigger that 100 (1 tenth of a second)

it is healthy( usage of CPU is negligible).




Regards.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Title # Comments Views Activity
How to create a duplicate finder Application 9 122
Validating VB6 Function 19 65
JSON Response and request in VB6 application 11 570
how to know if my Checkbox is True in VB6.0? 9 60
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…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

808 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