VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Loop's through the filesystem in VB.NET

by BUBA_KING (6 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Wed 13th June 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Loop's through the filesystem in VB.NET

API Declarations


'makes a file with a list of all the files on you computer and desplays on a console
'call the find sub folders.

Rate Loop's through the filesystem in VB.NET



        'On Error Resume Next
        If path = "" Then path = "e:\"
        Dim dirs() As System.IO.Directory
        Dim fold As System.IO.Directory
        dirs = system.IO.Directory.GetDirectoriesInDirectory(path)
        For Each fold In dirs
            'If fold.Attributes = System.IO.FileSystemAttributes.Directory Then
            Try
                console.WriteLine(fold.ToString) ' just an acsaple how to use this code
                mywr.writeline(fold.ToString)
                Call FindFiles(fold.ToString) 'find files in dir
                path = fold.ToString
                Call FindSubFolders()  'Recall to get the sub folders :=)
            Catch
                'donothing
            End Try
        Next

        
    End Sub
    Sub findfiles(ByVal path As String)
        Dim files() As system.IO.File
        Dim file As System.IO.file
        
        Try
            files = system.IO.Directory.GetFilesInDirectory(path)
            
            For Each file In files
                mywr.writeline(" * " & file.name)
                totsize = totsize + file.length
                console.WriteLine("* " & file.Name & ", " & file.Length)
            Next
            
        Catch
        End Try
        
    End Sub

Download this snippet    Add to My Saved Code

Loop's through the filesystem in VB.NET Comments

No comments have been posted about Loop's through the filesystem in VB.NET. Why not be the first to post a comment about Loop's through the filesystem in VB.NET.

Post your comment

Subject:
Message:
0/1000 characters