Re: Dir() question

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



As well as the locking issues (which can be freed using a token call to
Dir$("nul")), and the re-entrancy issues, there are also wildcard issues
with Dir$ Rob. See
http://groups.google.ie/group/microsoft.public.vb.general.discussion/msg/a0ff878889e6f52f
for a mention.

Tony Proctor

"Robert Morley" <rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:Oy9WnBfhHHA.4732@xxxxxxxxxxxxxxxxxxxxxxx
Ah, okay, I was aware of the directory locking issues of Dir() and the
possibility of competing Dir() commands getting confused. I hadn't
considered going with the API commands, though. For my purposes, it's
unlikely to matter, but it's something I'll look into later, when I have
more time to revise my code.


Thanks,
Rob

"J French" <erewhon@xxxxxxxxxx> wrote in message
news:462c5b39.4097212@xxxxxxxxxxxxxxxxxxxxxxx
On Sun, 22 Apr 2007 17:31:49 -0400, "Robert Morley"
<rmorley@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

Hi Mike,

Dir is not a good choice for this for a number of reasons.

Can you elaborate on this a bit more?

If you are in a Dir() loop, then another call to Dir upsets the loop
- you can't have more than one running at a time

As a result it is generally good policy to avoid the use of Dir()
especially in 'buried' routines.

The best solution is to use the FindFirstFile / FindNextFile /
FindClose APIs

However, in this case the GetAttr function will work fine, although
there have been reports that it misbehaves on some networks, I think
those problems were legacy.

To be honest I doubt if GetAttr is any faster, as it still has to
locate the file in the directory structure
- but using it will save potential grief from disrupted Dir routines




.



Relevant Pages

  • Re: Dir() question
    ... If you are in a Dirloop, then another call to Dir upsets the loop ... especially in 'buried' routines. ... However, in this case the GetAttr function will work fine, although ...
    (microsoft.public.vb.general.discussion)
  • Re: Dir() question
    ... it's definitely good to post it again, so anybody reading the thread can ... If you are in a Dirloop, then another call to Dir upsets the loop ... especially in 'buried' routines. ... However, in this case the GetAttr function will work fine, although ...
    (microsoft.public.vb.general.discussion)
  • Re: generic routines, to what end?
    ... almost identical code, and to endure the consequent pain of having to ... The specific routines must have the ... cases you are faced with writing clever obscure code that abstracts ... loop, and each pass through the loop outputs a new version of the ...
    (comp.lang.fortran)
  • Re: HP35s - solving functions in user programs
    ... user-programmed routines. ... wonder why the HP-35s cannot solve certain user routines just as the 34C ... => SOLVING ... Now try the same function with a loop inside: ...
    (comp.sys.hp48)
  • HC08 and RAM bootloader routine
    ... self-contained S19 file for a RAM-based message loop. ... contains FLASH programming routines and acts upon subsequent messages ... -nothing else uses this block of RAM and my stack is located at the ...
    (comp.arch.embedded)