0

Possible Duplicate:
Get a list of all files inside of a directory in vb.net

I need to search many file in a network drive. It is very slow to use the search function one by one in Window explorer under XP. My plan is to create a VB program to generate a whole list of available files in string format first, then use string search function in the list. My question is how to create a directory list using VB?

Thanks

Community
  • 1
  • 1
Marco
  • 985
  • 7
  • 22
  • 50
  • See MSDN: http://msdn.microsoft.com/en-us/library/07wt70x2.aspx#Y0 for `Directory.GetFiles()` method. Or see this question: http://stackoverflow.com/q/1457525/210709 – IAbstract Sep 02 '12 at 17:06
  • Would you please put your comment to the answer section. I will mark that you give the answer. – Marco Sep 02 '12 at 17:13

4 Answers4

1

See MSDN: Directory.GetFiles() method.

IAbstract
  • 19,551
  • 15
  • 98
  • 146
1

Someone had answered a somewhat similar question I found here, enter link description here I might suggest trying using a contains method to check if an item contains a string and then adding this to a second list to contain possible matches. Something like

Imports System
Imports System.IO
Public Function GetFileMatches(byval searchText as string) as list(of string)

Dim fileMatches as new list(of string)

for each directory in GetDirectories("c:\", "*")
       for each file in GetFiles(directory,"*")
          if file.contains(searchText) then fileMatches.add(file)
       next

next

return fileMatches
End Function

Might be able to apply some threading to speed it up as well.

Community
  • 1
  • 1
0

you can use FileSystemObject for this.

you can refer the link

0

You don't even need to use VB, just do

dir *.* /s > filelist.txt

And it will output the directory listing to file filelist.txt and you can open it in notepad.

Jesse
  • 1,937
  • 3
  • 19
  • 28