?
Solved

Perform an action during a FileSearch

Posted on 1998-11-09
5
Medium Priority
?
200 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
ID: 1443985
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
ID: 1443986
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
ID: 1443987
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 450 total points
ID: 1443988
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
ID: 1443989
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

840 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