Imports System
Imports System.IO
Public Class Test
Public Shared Sub Main()
Dim sourceDir As String = "c:\"
Dim backupDir As String = "c:\archives"
Try
Dim txtList As String() = Directory.GetFiles(sourceDir, "*.txt")
For Each f As String In txtList
Dim fName As String = f.Substring(sourceDir.Length + 1)
Try
File.Copy(Path.Combine(sourceDir, fName), Path.Combine(backupDir, fName))
Catch copyError As IOException
Console.WriteLine(copyError.Message)
End Try
Next
Catch dirNotFound As DirectoryNotFoundException
Console.WriteLine(dirNotFound.Message)
End Try
End Sub
End Class