Results 1 to 5 of 5

Thread: File

  1. #1

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    Post

    I would like to list the filenames of all files in "C:\My Documents"
    How do I do this?

    I can count them with this but I need to list their names.'count files in a directory

    Dim iFiles As Integer
    Dim sDir As String
    sDir = Dir("C:\My Documents\*.*", vbNormal)
    While sDir <> ""
    iFiles = iFiles + 1
    sDir = Dir
    Wend

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    Add something like MsgBox "The name of file number " & iFiles & " is " & sDir after the iFiles = iFiles + 1 line.


    ------------------
    Marty

  3. #3
    Lively Member
    Join Date
    Nov 1999
    Posts
    98

    Post

    i think you would do something like this...

    Dim iFiles As Integer
    Dim sDir As String
    sDir = Dir("C:\My Documents\*.*", vbNormal)
    While sDir <> ""
    'if youwant to keep count...
    iFiles = iFiles + 1
    'to add them to a listbox
    List1.Additem sDir
    sDir = Dir
    Wend

    --michael

  4. #4
    Lively Member
    Join Date
    Jun 1999
    Posts
    120

    Post

    why don't you use the file control "FileListBox"?

    e.g.
    File1.Path = "C:\My Documents"

  5. #5

    Thread Starter
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    Post

    Thank you all..

    I have it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width