Imports System.IO Imports System.Text Public Class Form1 Dim TargetFileText As New StringBuilder 'declare it outside any function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Dim files() As String 'Dim fileList As New System.Text.StringBuilder 'Dim myDate As DateTime = Me.dtpModified.Value 'Dim fileInfo As IO.FileInfo GetFiles(Me.txtDirectory.Text, Me.dtpModified.Value, ".ASPX") 'files = IO.Directory.GetFiles(Me.txtDirectory.Text, "*.*") 'For i As Integer = 0 To files.Length - 1 ' fileInfo = New IO.FileInfo(files(1)) ' If fileInfo.LastWriteTime > myDate And fileInfo.Extension.ToUpper() = ".ASPX" Then ' fileList.Append(files(i)) ' fileList.Append(Environment.NewLine) ' End If 'Next Dim writer As New IO.StreamWriter(Me.txtOutput.Text) writer.Write(TargetFileText.ToString) writer.Close() MsgBox("The file with all latest changes is created") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' Show the FolderBrowserDialog. Dim result As DialogResult = FolderBrowserDialog1.ShowDialog() If (result = DialogResult.OK) Then Me.txtDirectory.Text = FolderBrowserDialog1.SelectedPath End If End Sub 'THIS FUNCTION WILL RECUSRSIVELY FIND FILES IN PARTICULAR FOLDER Private Sub GetFiles(ByVal DirName As String, ByVal LastDate As Date, ByVal Ext As String) Dim d As DirectoryInfo = New DirectoryInfo(DirName) Dim f() As FileInfo = d.GetFiles() Dim Counter As Integer Counter = 0 ' TargetFileText.Append(vbCrLf + "-------------------------------------------------" + vbCrLf) 'TargetFileText.Append("Directory: " & d.FullName & vbCrLf) 'TargetFileText.Append("Name" & vbTab & vbTab & "Bytes" & vbTab & "Last Modified" & vbCrLf) Dim fi As FileInfo For Each fi In f If fi.Extension.ToUpper = Ext And fi.LastWriteTime > LastDate Then Counter = Counter + 1 If Counter = 1 Then TargetFileText.Append("Directory: " & d.FullName) End If TargetFileText.Append(Counter.ToString & vbTab & fi.Name) ' & vbTab & fi.Length & vbTab & fi.LastWriteTime & vbCrLf) End If Next Dim innerFolders As DirectoryInfo For Each innerFolders In d.GetDirectories() GetFiles(innerFolders.FullName, LastDate, Ext) Next End Sub End ClassUPDATE. Forgot to add a new line.