Solved

Perform an action during a FileSearch

Posted on 1998-11-09
5
190 Views
Last Modified: 2012-05-04
I'd like to know if it is possible to perform an action on the files returned by a filesearch WHEN the search is executing. I'm trying to write a program that will look into a folder and its sub-folders, find all the files haven't been accessed for a certain time, and then rename them. I know the DateLastAccessed property lets me distinguish the files, and the FileSearch method can find the files for me. But if I have to rename the files after the FileSearch, the result list could be huge. Is there any other way to do it? Please advise and thank you.
0
Comment
Question by:jluck
  • 3
5 Comments
 
LVL 2

Expert Comment

by:dabellei
Comment Utility
Every time you find a file use the dovents this will permit you to execute an action at this moment and return to your search after it, and at the same time you can advise the user wich file is update or rename in a label.

0
 

Author Comment

by:jluck
Comment Utility
Thanks, but dabellei could you please be more specific about your answer? I can't find any document about "dovents". Thanks.
0
 

Author Comment

by:jluck
Comment Utility
Oh, if you mean DoEvents, please specify how I show trigger the action. Meaning what condition I should use in the IF statement, in order to stop the search everytime it finds the right file. Thanks.
0
 
LVL 2

Accepted Solution

by:
dm_14 earned 150 total points
Comment Utility
1. Use the Dir command to look at a specific folder
2. for each file returned check its attribute
3. if its attribute is vbdirectory then this is a subdirectory which you will have to look through once you finish processing the current directory (you could store this dir info in an array)
4. if its attribute is a file (not vbdirectory) then check its last accessed time and if required rename the file
5. repeat 2 until no files are returned from the dir function
6. Then pass the array in 3. back to 1.

Use the Doevents in the For .. Next section this will allow your Users to stop the process if required.
0
 

Author Comment

by:jluck
Comment Utility
Thanks for your answer. Unfortunately my intention is to avoid arrays, cause this could be a big problem when you don't know the size limit. Anyway I found the solution to my problem, which is quite similar to your approach. I am accepting your answer, but I'd like to give 50 points to dabellei cause he/she was quite right in the first place. Hope you both are happy with this arrangement. Thanks.
0

Featured Post

Highfive Gives IT Their Time Back

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

743 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