Home > Archive > Visual Basic > December 2005 > Dir$ - differentiate folder and zip files
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Dir$ - differentiate folder and zip files
|
|
| Simon Woods 2005-12-14, 6:56 pm |
| Hi
I've a little app which invokes
l_sFolder = Dir$(m_sPath, vbDirectory)
I'm finding that it is returning, certainly on XP, zip files as well as
folders.
1) Can I exclude zip files in someway
2) If not, is there a way of testing to see whether the file is a zip
file (not by it's extension please)?
Thanks
Simon
| |
| Bob Butler 2005-12-14, 6:57 pm |
| "Simon Woods" <simonSPAMMENOT.woods@virginNOTMESPAM.net> wrote in
message news:%23yoswlLAGHA.1408@TK2MSFTNGP15.phx.gbl
> Hi
>
> I've a little app which invokes
>
> l_sFolder = Dir$(m_sPath, vbDirectory)
>
> I'm finding that it is returning, certainly on XP, zip files as well
> as folders.
Dir$ *ALWAYS* returns regular files, be they ZIP, DOC, TXT or whatever. It
normally does not return folder names but will add them if you specify
vbDirectory. What you are seeing is normal.
> 1) Can I exclude zip files in someway
No
> 2) If not, is there a way of testing to see whether the file is a
> zip file (not by it's extension please)?
Probably, but it's much more effective to test if it is a directory:
If getattr(m_sPath & "\" & l_sFolder) And vbDirectory Then
If l_sFolder<>"." and l_sFolder<>".." then
msgbox "found folder " & l_sFolder
End if
end if
Note that you may want to wrap the test into it's own procedure or otherwise
add error handling since it's theoretically possible for it to be deleted or
inaccessible when you go to check the attributes.
--
Reply to the group so all can participate
VB.Net: "Fool me once..."
| |
| Simon Woods 2005-12-14, 6:57 pm |
| Thanks Bob
"Bob Butler" <tiredofit@nospam.com> wrote in message
news:ehk7lDMAGHA.984@tk2msftngp13.phx.gbl...
> "Simon Woods" <simonSPAMMENOT.woods@virginNOTMESPAM.net> wrote in
> message news:%23yoswlLAGHA.1408@TK2MSFTNGP15.phx.gbl
>
> Dir$ *ALWAYS* returns regular files, be they ZIP, DOC, TXT or whatever.
> It
> normally does not return folder names but will add them if you specify
> vbDirectory. What you are seeing is normal.
>
>
> No
>
>
> Probably, but it's much more effective to test if it is a directory:
> If getattr(m_sPath & "\" & l_sFolder) And vbDirectory Then
> If l_sFolder<>"." and l_sFolder<>".." then
> msgbox "found folder " & l_sFolder
> End if
> end if
>
> Note that you may want to wrap the test into it's own procedure or
> otherwise
> add error handling since it's theoretically possible for it to be deleted
> or
> inaccessible when you go to check the attributes.
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>
|
|
|
|
|