Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / December 2004



Tip: Looking for answers? Try searching our database.

VB6 - How to determine whether contains FILES; not just FOLDERS???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alan Mailer - 30 Dec 2004 20:09 GMT
The Subject line kinda says it all.  I'm trying to find the most
efficient way in VB6 of determining whether a particular Folder
contains only sub folders.  If the Folder contains even one File, I'm
going to want the function I'm writing to return True.

What is the most efficient way of going about this?

Thanks in advance.
Veign - 31 Dec 2004 01:25 GMT
Private Function HasFiles(ByVal strPath As String) As Boolean

If Len(Dir(strPath, vbHidden Or vbNormal Or vbSystem Or vbReadOnly)) > 0
Then
   HasFiles = True
End If

End Function

or if you dont want to use the DIR function and risk affecting another part
of your application then try:
http://vbnet.mvps.org/code/fileapi/recursivefiles_minimal_multipleselective.htm

and just exit if one file is found - should be very fast.

Signature

Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

> The Subject line kinda says it all.  I'm trying to find the most
> efficient way in VB6 of determining whether a particular Folder
[quoted text clipped - 4 lines]
>
> Thanks in advance.
Randy Birch - 31 Dec 2004 06:23 GMT
I've just tossed up a fast routine using FindFirst/Next to return true if a
folder contains 1 file or more, and another to test for subfolders.

Signature

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

: Private Function HasFiles(ByVal strPath As String) As Boolean
:
[quoted text clipped - 7 lines]
: or if you dont want to use the DIR function and risk affecting another part
: of your application then try:

http://vbnet.mvps.org/code/fileapi/recursivefiles_minimal_multipleselective.htm

: and just exit if one file is found - should be very fast.
:
[quoted text clipped - 6 lines]
: >
: > Thanks in advance.
Veign - 31 Dec 2004 15:19 GMT
Even better...Thanx Randy

Signature

Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--

> I've just tossed up a fast routine using FindFirst/Next to return true if a
> folder contains 1 file or more, and another to test for subfolders.
[quoted text clipped - 11 lines]
> part
> : of your application then try:

http://vbnet.mvps.org/code/fileapi/recursivefiles_minimal_multipleselective.htm

> : and just exit if one file is found - should be very fast.
> :
[quoted text clipped - 6 lines]
> : >
> : > Thanks in advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.