Results 1 to 6 of 6

Thread: copy filenames to multiple strings

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    24

    copy filenames to multiple strings

    as a part of an ongoing project im trying to take the name from every file in a folder and copy each filename to a seperate string... anyone know how i can go about doing this? ive found some code that takes the number of files in a given folder so i thought i might be able to use "For x = 1 To fldr.Files.Count" but beyond this, i dont know how to make an individual string for each filename nor how to copy the filename to the string... any hwlp is greatly appreciated
    Last edited by blackmomba69; Aug 18th, 2005 at 02:54 PM.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: copy filenames to multiple strings

    VB Code:
    1. DIm tmp as string
    2. Dim Files() as string
    3. Dim cntr as integer
    4. cntr = 0
    5. tmp = Dir("C:\Path\*.*")
    6. Do while tmp > ""
    7.     redim preserve Files(cntr)
    8.     Files(cntr) = tmp
    9.     tmp = Dir
    10.     cntr = cntr + 1
    11. Loop

    now to get them back out
    for x = 0 to ubound(Files)
    msgbox Files(X)
    next
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    24

    Re: copy filenames to multiple strings

    what about folders? how would i get every folder name to a string?

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: copy filenames to multiple strings

    change this:
    tmp = Dir("C:\Path\*.*")
    to
    tmp = Dir("C:\Path\*.*",vbDirectory)

    and it will have directories to.. (Just check for an extention)

    this can also be done with FSO (File System Object)
    which will give you more control... (Do a search on FSO or FileSystemObject)
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    24

    Re: copy filenames to multiple strings

    alright, thanks alot

  6. #6
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: copy filenames to multiple strings

    If you use FSO, you need to remember that you have to add the refference for scrrun.dll file to your project.

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