Home All Groups Group Topic Archive Search About
Author
2 Mar 2009 4:36 PM
Simon Woods
Hi

I am testing for the existence of a folder using

    FolderExists = (Dir$(FolderName, vbDirectory) = ".")

I'm finding that prior to executing this command I can go into explorer
and rename the folder okay. Once this has been executed, I am informed
that it is now in-use so I can't rename it.

I wondering what I can do so that I can rename the folder. (I'm using XP
SP3)

Any suggestions? Thx.

Simon

Author
2 Mar 2009 4:45 PM
Simon Woods
Okay so I changed to

     FolderExists = (GetAttr(FolderName) = vbDirectory)

which seems to work

Thx


Simon Woods wrote:
Show quoteHide quote
> Hi
>
> I am testing for the existence of a folder using
>
>    FolderExists = (Dir$(FolderName, vbDirectory) = ".")
>
> I'm finding that prior to executing this command I can go into explorer
> and rename the folder okay. Once this has been executed, I am informed
> that it is now in-use so I can't rename it.
>
> I wondering what I can do so that I can rename the folder. (I'm using XP
> SP3)
>
> Any suggestions? Thx.
>
> Simon
Author
2 Mar 2009 4:58 PM
Bob Butler
"Simon Woods" <simonjwo***@hotmail.com> wrote in message
news:%23cvvIZ1mJHA.3876@TK2MSFTNGP02.phx.gbl...
> Okay so I changed to
>
>     FolderExists = (GetAttr(FolderName) = vbDirectory)
>
> which seems to work

Unless other attributes are set on the folder...
CBool(GetAttr(foldername) And vbDirectory)

which can still give a false return if access is denied but is often good
enough

> Simon Woods wrote:
>> Hi
>>
>> I am testing for the existence of a folder using
>>
>>    FolderExists = (Dir$(FolderName, vbDirectory) = ".")

"." is not always returned so that's never a good way to test

>> I'm finding that prior to executing this command I can go into explorer
>> and rename the folder okay. Once this has been executed, I am informed
>> that it is now in-use so I can't rename it.
>>
>> I wondering what I can do so that I can rename the folder. (I'm using XP
>> SP3)
>>
>> Any suggestions? Thx.

Dir$ opens the folder so you need to close it by opening another folder;
IIRC using dir$("nul") works but it's been a while and I'm not in a position
to test it right now.
Author
3 Mar 2009 7:54 AM
Simon Woods
Bob Butler wrote:

<snip>

Thx very much Bob

S