Getting directory list of a folder's contents 
Author Message
 Getting directory list of a folder's contents

I'd like to write an app that cycles thru a specific folder's contents
and performs operations on each file contained within. How do I get that
list, or is it easier to use a command that cycles thru a specific
directlry?

Thanks for any information.

--
Bob Patin
Longterm Solutions

 ** delete NOSPAM to reply via email **



Wed, 07 Nov 2001 03:00:00 GMT  
 Getting directory list of a folder's contents
Look up the Dir function in the docs.  Good Luck.  


Quote:

>I'd like to write an app that cycles thru a specific folder's contents
>and performs operations on each file contained within. How do I get that
>list, or is it easier to use a command that cycles thru a specific
>directlry?

>Thanks for any information.

>--
>Bob Patin
>Longterm Solutions

> ** delete NOSPAM to reply via email **

Paul Hewson  paulh(a)vif.*Delete*This*.com
-------------------------------------------
  e-mail altered to foil auto-spammers  

-------------------------------------------
Recursive, adj.; see Recursive


Fri, 09 Nov 2001 03:00:00 GMT  
 Getting directory list of a folder's contents

Quote:

> I'd like to write an app that cycles thru a specific folder's contents
> and performs operations on each file contained within. How do I get that
> list, or is it easier to use a command that cycles thru a specific
> directlry?

> Thanks for any information.

> --
> Bob Patin
> Longterm Solutions

>  ** delete NOSPAM to reply via email **

Solutions:
1. You can use a folder list box, set it onto the folder you want (by
code, if necessary), then browse thru the items in the list.
2. Use the file system object of the scripting runtime (scrrun.dll) to
obtain a list of files in a specific folder.
3. FindFirstFile/FindNextFile/FindClose APIs

Very simple example using method 1:
Add a DirListBox & a FileListBox. Make both invisible.

Private Sub Form_Load()

    Dir1.Path = "C:\Winnt40\"
End Sub

Private Sub Dir1_Change()

    Dim intI As Integer

    With File1
        .Path = Dir1.Path
        For intI = 0 To .ListCount
            Debug.Print .List(intI)
        Next intI
    End With
End Sub

Very simple example using method 2:

Option Explicit

Dim m_objFSO As Scripting.FileSystemObject

Private Sub Form_Load()

    Set m_objFSO = New Scripting.FileSystemObject
    CheckFolder "C:\Winnt40\system32\"
    Set m_objFSO = Nothing
End Sub

Private Sub CheckFolder(strPath As String)

    Dim objFolder As Scripting.Folder
    Dim objLoopFile As Scripting.File

    Screen.MousePointer = vbHourglass
    Set objFolder = m_objFSO.GetFolder(strPath)

    For Each objLoopFile In objFolder.Files
        Debug.Print objLoopFile.Name
    Next objLoopFile

    Set objFolder = Nothing
    Screen.MousePointer = vbNormal
End Sub



Mon, 26 Nov 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. getting a directory's contents

2. getting a directory's contents

3. getting list of directories into list box

4. Getting Directory Contents in VB

5. getting the directory contents in vb

6. Getting the contents of a directory

7. List Directory Contents in Menu

8. Listing Contents of Web Directory

9. how to list directory contents

10. Listing the contents of a directory through script?

11. List contents of a directory

12. Showing contents of a directory in a list box

 

 
Powered by phpBB® Forum Software