files from subfolder
-
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
-
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
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
-
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
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 Ifdnpro "Very bad programmer"