Solved

Flushing Kill, FileCopy, etc...

Posted on 1999-01-28
5
178 Views
Last Modified: 2010-05-03
Can anyone tell me how to refresh the directory listing that VB5's "dir" command references?  It is not refreshing quickly enough for my application, and it is returning a null string where a file has absolutely been copied.
0
Comment
Question by:NickH
[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
5 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 1471075
Did you tried a DoEvents before your Dir command.
0
 
LVL 14

Expert Comment

by:waty
ID: 1471076
You have to re-create your dir command in order to take the new files in consideration.

sFile = Dir("*.bas")

0
 

Author Comment

by:NickH
ID: 1471077
This doesn't look like a recreation command, but more like simply issuing the command again.  This is where dir is failing...it is looking at some outdated file listing cache, and doesn't see the changes I've made with FileCopy.

emoreau:
I tried DoEvents tree times in a row on the client side, and it didn't seem to work.
0
 

Author Comment

by:NickH
ID: 1471078
Adjusted points to 60
0
 
LVL 2

Accepted Solution

by:
dm_14 earned 60 total points
ID: 1471079
Try this

(1) Check the directory you are interested in
   eg Dir ("C:\windows\*.dll")
(2) Check the root directory
   eg Dir ("C:\noexist.txt")
(3) Then recheck the directory you are interested in
   eg Dir ("C:\windows\*.dll")

The idea is that after you have finsihed checking the directory you are interested in then switch to another directory and then back to the one you are interested in and then search for files.

(If you are trying to create a file listener ie. a program that does something everytime a file appears or is modified in a directory then you should use the FindFirstChangeNotification and FindNextChangeNotification API commands)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

749 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