Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Watching a folder for file population

Posted on 2004-08-17
6
Medium Priority
?
334 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
[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
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 2000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses

730 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