Re: Slow response using DIR or FSO when there are many files in a folder

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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 file
in
the list (and they are all .jpg images). The disk seems to grind away for
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
VB6.

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
the
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..."





.



Relevant Pages

  • Re: Need Help With CHKDSK
    ... How does the partition show up in Disk Management (a screenshot would be ... Should the file system be NTFS? ... "Bob The Builder" wrote in message ... > Check Disk is not available for this disk type" ...
    (microsoft.public.win2000.file_system)
  • Re: install help
    ... > Bob Bailin wrote: ... >>> driver for the other card attached to the tape drive. ... >> Also, make sure that the hard disk is plugged into the first bus, ... > Plugging the cable into the other channel did the trick. ...
    (comp.unix.sco.misc)
  • Re: Computer Having Trouble Booting
    ... Bob L. wrote: ... think that if your disk is repeatedly refusing to boot after a short time of use it is going bad, disks can fail at anytime for any reason, age is not an indication that a disk is OK, they can fail right out of the box or within a few months of installation. ... When I boot the master drive I get an error. ... The only way I can start the computer at this point is to use a boot disk and boot an operating system on the slave drive. ...
    (microsoft.public.windowsxp.general)
  • Re: network dd-image
    ... Ron Eggler wrote: ... > Bob Bob wrote: ... >> though to not do this with a running filesystem as the source. ... Imagine the dd process is currently dumping the journal on the file system, ...
    (alt.os.linux.suse)
  • Re: reinstall of XP
    ... >> A friend has an IBM model 6892-n9u that was running XP Pro SP2 that ... >> from a WIN98 boot disk but that is as far as I get. ... To Bob, in case you miss the link to my BIOS page, check it for how to ...
    (microsoft.public.windowsxp.help_and_support)