Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursive File Search
12-21-2009, 12:41 PM (This post was last modified: 12-21-2009 08:53 PM by drdebcol.)
Post: #1
Recursive File Search
This will list all Directories -> Sub Directories - > Files within a specific directory. You could quite easily filter which files/file types you wanted to be displayed but I will let you figure that out Smile

Code:
' Recursive Search by FreckleS
' GamesAlter.com
' Malwares-In.net
' Pro9ramming.com

Imports System.IO
Module Module1
    Sub Main()
        Search("C:\") ' Which directories to search
        Console.ReadLine() ' Display Output
    End Sub

    Sub Search(ByVal directoryPath)
        Dim files() As String ' Unset array of files
        Dim directories() As String ' Unset array of directories

        files = Directory.GetFiles(directoryPath) ' Load all files
        For Each File In files ' Each file
            Console.WriteLine(File)
        Next ' Get the next file

        directories = Directory.GetDirectories(directoryPath) ' Load all the sub directories
        For Each Directory In directories ' Each directory/sub directory
            Console.WriteLine(Directory) ' This will write the directory (not needed but you can use)
            Search(Directory) ' Go again in new directory
        Next ' Get the next directory
    End Sub
End Module

[Image: pgsig copy.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
12-21-2009, 08:53 PM
Post: #2
RE: Recursive File Search
Very good i can say ! Good algorithm.

OFFTOPIC :
I edited your post because you put name of this iste "pro9gramming.com" and it is "pro9ramming.com" there is one "g" more.
It is because "9" is "g".

"I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein
Visit this user's website Find all posts by this user
Quote this message in a reply
12-21-2009, 09:03 PM
Post: #3
RE: Recursive File Search
Ah woops lol...No problems thanks for the nice comment Big Grin

[Image: pgsig copy.png]
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: