Re: Slow response using DIR or FSO when there are many files in a folder
- From: "Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 5 Apr 2006 16:45:06 +0100
Have you actually tried what Bob was suggesting Jerry?
Have you tried the same Dir() or FSO operation twice in succession? If so,
is the 2nd run quicker. The point I think Bob and myself are getting at is
that the directory files are cached in the file system cache, just like any
other type of file. Hence, once a large directory file has been implicitly
loaded (either by VB or by a Command shell), and so is currently held in
virtual memory by the system cache, then subsequent operations on it should
be a whole lot quicker.
Tony Proctor
"Jerry Spence1" <jerry.spence@xxxxxxxxxxxxx> wrote in message
news:442ace25$0$3610$ed2e19e4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Ah - nice point except that I'm actually only looking for the first filein
the list (and they are all .jpg images). The disk seems to grind away forVB6.
ever before returning it. BTW I have an NTFS disk and a feature of this is
that it is ordered alphbetically (and the first one I need is the lowest
alpha filename), so internally they might not be ordered in this way.
However it still doesn't explain why the first one (and all the others)
comes up immediately under cmd and over a minute using DIR or fso under
the
I'll have a look at the FindFirstFile API. I wasn't aware of that one.
Thanks
-Jerry
"Bob Butler" <tiredofit@xxxxxxxxxxx> wrote in message
news:uEjaVSzUGHA.5500@xxxxxxxxxxxxxxxxxxxxxxx
"Jerry Spence1" <jerry.spence@xxxxxxxxxxxxx> wrote in message
news:442a4f3f$0$6992$ed2619ec@xxxxxxxxxxxxxxxxxxxxxxxxxx
I have many small .jpg files in many folders. There could be about
15,000. I am trying to get the file name of the first one and I have
tried Myfile = DIR ("*.jpg") and also fso. This is an incredibly slow
operation and it may well be a minute or two before it returns the
filename. I can hear the disk grinding away for all this time. I
thought it was a 'feature' of XP, or the file system, but if I go
into a cmd prompt, go to the same folder and type DIR, it lists the
files immediately.
Have you tried doing the command prompt first and then using the DIR
function? It sounds like the OS is caching the disk information after
first access. Other than using DIR you can try the FindFirstFile and
related API calls which would probably be a bit faster.
--
Reply to the group so all can participate
VB.Net: "Fool me once..."
.
- Prev by Date: Re: Checkbox/pressed button: First click only sets focus
- Next by Date: Re: RaiseEvent doesn't Raise Event
- Previous by thread: Trim String Array of empty values
- Next by thread: Problem with Timer firing reliably
- Index(es):
Relevant Pages
|