/ Published in: VB.NET
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Imports System.IO Private Sub CopyFiles(ByVal sSource As String, ByVal sDestination As String, Optional ByVal sExtension As String = "*.csv", Optional ByVal blnOverWrite As Boolean = False) If Directory.Exists(sSource) = False Then MessageBox.Show("Source directory doesn't exist", "Source Directory Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If If Directory.Exists(sDestination) = False Then MessageBox.Show("Destination directory doesn't exist", "Destination Directory Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If Dim fil As FileInfo Dim diSourceDir As New DirectoryInfo(sSource) Try For Each fil In diSourceDir.GetFiles(sExtension) fil.CopyTo(Path.Combine(sDestination, fil.Name), blnOverWrite) Next Catch ex As Exception ' Probably read only End Try End Sub
URL: http://bytes.com/groups/net-vb/378353-copying-multiple-files