getting the directory contents in vb 
Author Message
 getting the directory contents in vb

Quote:

>I want a simple function that returns a list of all the files in a directory.
>How do I do taht in VB?  DIR doesn't do it.

Dir certainly does do it:

    Dim sFile As String
    sFile = Dir("c:\*.*")
    While Len(sFile)
        List1.AddItem sFile
        sFile = Dir
    Wend

Lee Weiner
weiner AT fuse DOT net



Tue, 13 Feb 2001 03:00:00 GMT  
 getting the directory contents in vb
<cut>

Quote:
>    While Len(sFile)
<cut>
>    Wend
>Lee Weiner
>weiner AT fuse DOT net

This brings up a question -- I don't often see the While/Wend construct and
the VB manuals & help barely seem to mention it.  Are there any advantages
or disadvantages between this and the more common Do/Loop construct?


Tue, 13 Feb 2001 03:00:00 GMT  
 getting the directory contents in vb
While-wend is generally considered a bit obsolescent (don't bother to flame
that if you like it, that's OK too) -- I have also read that it might not
compile into such well optimized code, but I can't remember where. Anyway,
there's nothing you can do with WW that you can't do with a Do Loop.

John



Quote:

> <cut>
> >    While Len(sFile)
> <cut>
> >    Wend
> >Lee Weiner
> >weiner AT fuse DOT net

> This brings up a question -- I don't often see the While/Wend construct
and
> the VB manuals & help barely seem to mention it.  Are there any
advantages
> or disadvantages between this and the more common Do/Loop construct?



Tue, 13 Feb 2001 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Getting Directory Contents in VB

2. getting a directory's contents

3. getting a directory's contents

4. Getting directory list of a folder's contents

5. Getting the contents of a directory

6. Getting ALL directories & sub directories

7. Getting Start Menu Directory and Favorites Directory Paths by API

8. getting directory size in vb

9. Help: Getting Desktop directory in VB

10. Getting Directory size in VB???

11. Getting directory structures in VB 5

12. Inserting directory contents into listbox

 

 
Powered by phpBB® Forum Software