Results 1 to 9 of 9

Thread: [RESOLVED] Getting all file names from all subfolders

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2018
    Posts
    61

    Resolved [RESOLVED] Getting all file names from all subfolders

    Hi! I have a question, how to get all file names from all subfolders and write it to a file? I tried a code, but It gets only the first subfolder level, and its files, what if in that subfolder is another subfolder, and in that, another? How to make a dynamic code, like not to write a for loop as many times as are there subfolders? Thank you!
    Code:
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim file As System.IO.StreamWriter
            file = My.Computer.FileSystem.OpenTextFileWriter("cuccli.txt", False)
            Dim mappa = System.IO.Directory.GetDirectories(hely)
            For i As Integer = 0 To mappa.Count - 1
                file.WriteLine(mappa(i).ToArray & " ---->")
                Dim fajl = System.IO.Directory.EnumerateFiles(mappa(i))
                For j As Integer = 0 To fajl.Count - 1
                    file.WriteLine("---" & fajl(j).ToArray)
                Next
                file.WriteLine("===================")
            Next
            file.Close()
        End Sub
    Last edited by Daveeed; Jan 10th, 2019 at 05:32 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width