Posted By

mafro on 05/09/07


Tagged

file


Versions (?)

File Copy


 / Published in: VB.NET
 

Utilises the Windows file copy dialog. Handles the cancel button.

  1. Private Structure FileCopy
  2. Public Source As String
  3. Public Destination As String
  4.  
  5. Public Sub New(ByVal source As String, ByVal dest As String)
  6. Me.Source = source
  7. Me.Destination = dest
  8. End Sub
  9. End Structure
  10.  
  11. Private Sub CopyFile(ByVal fc As FileCopy)
  12. Try
  13. My.Computer.FileSystem.CopyFile(AppController.TemplatePath & fc.Source, _
  14. AppController.TemplatePath & fc.Destination, Microsoft.VisualBasic.FileIO.UIOption.AllDialogs)
  15.  
  16. Catch ocex As OperationCanceledException
  17. 'cancel pressed!
  18. If IO.File.Exists(AppController.TemplatePath & fc.Destination) Then
  19. IO.File.Delete(AppController.TemplatePath & fc.Destination)
  20. End If
  21.  
  22. Exit Sub
  23. End Try
  24. End Sub

Report this snippet  

You need to login to post a comment.