|
-
Apr 4th, 2000, 11:51 PM
#1
Thread Starter
Member
I have this code to return a directory listing in a folder
dir1=dir("c:\myfolder")
do until dir()=""
dir1=dir
loop
My problem is that I want to see the last file that would show up in the name column under details.
But if files names have spaces in them it does not like that
Anyone have any advice
thanks
-
Apr 5th, 2000, 12:00 AM
#2
Thread Starter
Member
It actually seems to genrate an error message when I add another file to that dir
why?
-
Apr 5th, 2000, 12:04 AM
#3
Addicted Member
Try this:
Code:
Dim sFile As String
sFile = Dir("c:\myfolder\", vbDirectory Or vbNormal Or vbReadOnly Or vbHidden Or vbSystem)
Do While sFile <> vbNullString
Debug.Print sFile
sFile = Dir
Loop
You may notice your main problem was that you forgot the backslash after the directory you wanted to list. Also, you almost always have specify the file types as well to get a true directory listing.
Later.
-
Apr 5th, 2000, 12:38 AM
#4
Fanatic Member
Try this:
Dim strExistingFile As String
strExistingFile = Dir(gstrProcessAreaDirectory & "*.*")
Do Until strExistingFile = ""
List1.Additem strExistingFile
strExistingFile = Dir()
Loop
Chemically Formulated As:
Dr. Nitro
-
Apr 5th, 2000, 12:44 AM
#5
Thread Starter
Member
These do work great, however, how can I sort them
-
Apr 5th, 2000, 12:44 AM
#6
Lively Member
Your problem is everytime the line do until dir()="" is executed you retrieve the next file. With the code you have you are retrieving every other file. Try using this code and see what you get.
dir1=dir("c:\myfolder")
do while dir1 <> ""
dir1=dir
loop
-
Apr 5th, 2000, 12:52 AM
#7
Addicted Member
If you're putting it into a ListBox simply set the Sorted property to True. Otherwise use something like a bubble sort on the list of files.
If you don't know how to do a bubble sort, ask me how and I post it. It does take some coding though.
-
Apr 5th, 2000, 12:57 AM
#8
Fanatic Member
Inside the listbox, there is a property call "Sort". Set this to "True" and there you have it.
Chemically Formulated As:
Dr. Nitro
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
|