Solved

Perform an action during a FileSearch

Posted on 1998-11-09
5
191 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 150 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vba find the last empty column 10 88
MS Acccess - Update Field in Table when report is printed 6 44
Add and format columns in vb6 7 47
Recommendation vb6 to vb.net or others 14 112
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…

895 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

12 Experts available now in Live!

Get 1:1 Help Now