Here's a method cobbled together from the FileSystemObject() examples using a recursive call. Apply a sort to the results if needed. You can also filter by .txt extension using other FileSystemObject() methods:
Sub Sample()
ShowFolderList ("C:\temp")
End Sub
Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s, sFldr
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 In fc
If Right(f1, 1) <> "\" Then ShowFolderList f1 & "\" Else ShowFolderList f1
Next
Set fc = f.Files
For Each f1 In fc
Debug.Print folderspec & f1.Name
Next
End Sub
Write to file:
Option Explicit
Dim file As Object
Dim fs As Object
Sub go()
Set fs = CreateObject("Scripting.FileSystemObject")
Set file = fs.OpenTextFile("C:\temp2\results3.txt", 2, True) ' 2=ForWriting, replace
ShowFolderList "C:\temp\"
file.Close
MsgBox "done"
End Sub
Sub ShowFolderList(folderspec)
On Error GoTo local_err
Dim f, f1, fc, s, sFldr
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 In fc
If Right(f1, 1) <> "\" Then ShowFolderList f1 & "\" Else ShowFolderList f1
Next
Set fc = f.Files
For Each f1 In fc
file.writeline folderspec & f1.Name
Next
local_exit:
Exit Sub
local_err:
MsgBox Err & " " & Err.Description
Resume local_exit
Resume
End Sub