Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. files from subfolder

files from subfolder

Scheduled Pinned Locked Moved Visual Basic
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jishbalan
    wrote on last edited by
    #1

    Hello all, Can any body helps me to find a code for getting files from subfolders or files inside that subfolder. i know code to get files from folders and subfolders. But if many folders are there, my code fails i.e. folder/subfolder/subfolder/... i am not sure how many subfolders are there inside a folder i need the code for getting file from folder/subfolder/subfolder/subfolder.. i am using these code for getting files inside subfolder For Each fld In path.SubFolders For Each fil In fso.GetFolder(fld.path).Files If Right(fil, 3) = "txt" Then fileNameArray1(fileCounts) = fil fileCounts = fileCounts+1 End If Next Next please try give the code for getting files inside folder/subfolder/subfolder/subfolder/.. Thanks and regards Jishith

    N A 2 Replies Last reply
    0
    • J jishbalan

      Hello all, Can any body helps me to find a code for getting files from subfolders or files inside that subfolder. i know code to get files from folders and subfolders. But if many folders are there, my code fails i.e. folder/subfolder/subfolder/... i am not sure how many subfolders are there inside a folder i need the code for getting file from folder/subfolder/subfolder/subfolder.. i am using these code for getting files inside subfolder For Each fld In path.SubFolders For Each fil In fso.GetFolder(fld.path).Files If Right(fil, 3) = "txt" Then fileNameArray1(fileCounts) = fil fileCounts = fileCounts+1 End If Next Next please try give the code for getting files inside folder/subfolder/subfolder/subfolder/.. Thanks and regards Jishith

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      You need a recursive function. This[^] KB article show how to do it in C#. Same can be ported to VB.NET.

      Navaneeth How to use google | Ask smart questions

      1 Reply Last reply
      0
      • J jishbalan

        Hello all, Can any body helps me to find a code for getting files from subfolders or files inside that subfolder. i know code to get files from folders and subfolders. But if many folders are there, my code fails i.e. folder/subfolder/subfolder/... i am not sure how many subfolders are there inside a folder i need the code for getting file from folder/subfolder/subfolder/subfolder.. i am using these code for getting files inside subfolder For Each fld In path.SubFolders For Each fil In fso.GetFolder(fld.path).Files If Right(fil, 3) = "txt" Then fileNameArray1(fileCounts) = fil fileCounts = fileCounts+1 End If Next Next please try give the code for getting files inside folder/subfolder/subfolder/subfolder/.. Thanks and regards Jishith

        A Offline
        A Offline
        Ashutosh Phoujdar
        wrote on last edited by
        #3

        The article mentioned in previous reply is perfect call for this situation. But, Now .NET supports recursive search by using simple code snippet. Have a look in following code snippet :

        Dim myFiles() As String = Directory.GetFiles("C:\Temp", "*.*", SearchOption.AllDirectories)

        If myFiles.Length > 0 Then
        'Do process list of files retrieved
        End If

        dnpro "Very bad programmer"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups