Valhalla Legends Forums Archive | Visual Basic Programming | Dir() Function

AuthorMessageTime
Lobo.id
Im useing the directory function to find files with a certain extension. Here's the code im useing so far.

[code]
Dim SFindFile as string
SFindFile = Dir(App.Path & "\*.ini")
lstprofile.Additem SFindFile
[/code]

Now I only get 1 file added to the listbox, but I have more then 1 in the directory. I tryed looping it but I don't think I did the loop right, maybe you can point out something that will help me. If not thanks for looking at it.
November 7, 2003, 3:40 AM
iago
http://visualbasicforum.com/showthread.php?t=99464&highlight=fso%2A

[quote]Hello,
I have a folder that has *.tif and *.txt files in it...
I want to point to the folder and read the file names. If the file names match my criteria i want to copy them to another folder.
I know how to point to a file within a folder using the commondialog. and read *.txt files but I dont know how to read in the files in a folder. How do I just read the file names in a folder so I can move the ones I that match the criteria?
Can anyone point me to a web page that might help?
Thanks.[/quote]


The question is answered there. I hope that helps! :)
November 7, 2003, 4:28 AM
Spht
After defining file mask you want to use with Dir, you can then use Dir with no parameters to continuously get the next matching file. After Dir returns nothing, then you've reached the end of the matching files.
November 7, 2003, 4:30 AM
Lobo.id
Thanks Spht, and Iago. Also sorry if I toke up any of your time with this question.
November 7, 2003, 4:37 AM
iago
Nope, I just did a quick google search for "visual basic dir" (without the quotes)
November 7, 2003, 4:45 AM

Search