Multiple File Copy


/ Published in: VB.NET
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Imports System.IO
  2.  
  3. Private Sub CopyFiles(ByVal sSource As String, ByVal sDestination As
  4. String, Optional ByVal sExtension As String = "*.csv", Optional ByVal
  5. blnOverWrite As Boolean = False)
  6. If Directory.Exists(sSource) = False Then
  7. MessageBox.Show("Source directory doesn't exist", "Source
  8. Directory Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  9. Exit Sub
  10. End If
  11. If Directory.Exists(sDestination) = False Then
  12. MessageBox.Show("Destination directory doesn't exist",
  13. "Destination Directory Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  14. Exit Sub
  15. End If
  16. Dim fil As FileInfo
  17. Dim diSourceDir As New DirectoryInfo(sSource)
  18. Try
  19. For Each fil In diSourceDir.GetFiles(sExtension)
  20. fil.CopyTo(Path.Combine(sDestination, fil.Name), blnOverWrite)
  21. Next
  22. Catch ex As Exception
  23. ' Probably read only
  24. End Try
  25. End Sub

URL: http://bytes.com/groups/net-vb/378353-copying-multiple-files

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.