Results 1 to 6 of 6

Thread: Reading files out of an directory

  1. #1

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Reading files out of an directory

    Is there a way to read which files are in a folder, preferrably putting the filenames in a string.

    Like:
    VB Code:
    1. Dim sFilenames() as String
    2.  
    3. Object.Folder = "C:\Folder\"
    4. sFilenames() = Object.FilesInFolder

    But then in a way that works.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

  2. #2
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724

    Re: Reading files out of an directory

    Originally posted by arsmakman
    Is there a way to read which files are in a folder, preferrably putting the filenames in a string.

    Like:
    VB Code:
    1. Dim sFilenames() as String
    2.  
    3. Object.Folder = "C:\Folder\"
    4. sFilenames() = Object.FilesInFolder

    But then in a way that works.

    try out FileSystemObject refer MSDN..... for examples

  3. #3

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719

    Re: Re: Reading files out of an directory

    Originally posted by khalik_ash
    try out FileSystemObject refer MSDN..... for examples
    I tried MSDN, but got nonethewiser,
    please post some code I can use for this.
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate it!

  4. #4
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Or rather than the API, you can use the DIR() function:
    VB Code:
    1. Private Sub Form_Load()
    2.     Dim strPathToSearch As String
    3.     Dim strCurrentPath As String
    4.    
    5.     strPathToSearch = "c:\"
    6.    
    7.     strCurrentPath = Dir(strPathToSearch, vbDirectory)
    8.    
    9.     Do While strCurrentPath <> ""
    10.         If strCurrentPath <> "." And strCurrentPath <> ".." Then
    11.             Text1.Text = Text1.Text & strCurrentPath & vbCrLf
    12.         End If
    13.         strCurrentPath = Dir
    14.     Loop
    15. End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6

    Thread Starter
    Fanatic Member arsmakman's Avatar
    Join Date
    Dec 2001
    Location
    Leiden, Netherlands.
    Posts
    719
    Cool!

    Thanx man!
    No matter how fool-proof your program is, there will always be a better fool.

    Was a post helpful to you? Rate 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