|
-
Aug 18th, 2005, 02:50 PM
#1
Thread Starter
Junior Member
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.
-
Aug 18th, 2005, 03:01 PM
#2
Re: copy filenames to multiple strings
VB Code:
DIm tmp as string
Dim Files() as string
Dim cntr as integer
cntr = 0
tmp = Dir("C:\Path\*.*")
Do while tmp > ""
redim preserve Files(cntr)
Files(cntr) = tmp
tmp = Dir
cntr = cntr + 1
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"
-
Aug 18th, 2005, 03:24 PM
#3
Thread Starter
Junior Member
Re: copy filenames to multiple strings
what about folders? how would i get every folder name to a string?
-
Aug 18th, 2005, 03:38 PM
#4
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"
-
Aug 18th, 2005, 03:53 PM
#5
Thread Starter
Junior Member
Re: copy filenames to multiple strings
alright, thanks alot
-
Aug 18th, 2005, 03:55 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|