16/07/13 14:13
danduz97
Salve a tutti.
sto sviluppando un software che permette di copiare sia directories che files. quindi ho creato il mio sub mettendo tutto sotto Try (nel caso ci fosse qualche errore il programma non si bloccherebbe)
solo che quando vado a testare il mio programma simulando un errore, si genera un loop infinito di eccezioni(sottoforma di MessageBox).. come farei a fermarlo facendo comparire una sola MsgBox?
ecco il mio sorgente:
Grazie infinite!
sto sviluppando un software che permette di copiare sia directories che files. quindi ho creato il mio sub mettendo tutto sotto Try (nel caso ci fosse qualche errore il programma non si bloccherebbe)
solo che quando vado a testare il mio programma simulando un errore, si genera un loop infinito di eccezioni(sottoforma di MessageBox).. come farei a fermarlo facendo comparire una sola MsgBox?
ecco il mio sorgente:
Public Sub CopyDirectory(ByVal sourcePath As String, ByVal destinationPath As String) Dim sourceDirectoryInfo As New System.IO.DirectoryInfo(sourcePath) If Not System.IO.Directory.Exists(destinationPath) Then System.IO.Directory.CreateDirectory(destinationPath) End If Dim fileSystemInfo As System.IO.FileSystemInfo Try For Each fileSystemInfo In sourceDirectoryInfo.GetFileSystemInfos Dim destinationFileName As String = System.IO.Path.Combine(destinationPath, fileSystemInfo.Name) If TypeOf fileSystemInfo Is System.IO.FileInfo Then System.IO.File.Copy(fileSystemInfo.FullName, destinationFileName, True) Else CopyDirectory(fileSystemInfo.FullName, destinationFileName) End If Next Catch ex As Exception MsgBox("errore") End Try End Sub
Grazie infinite!
Ultima modifica effettuata da danduz97 16/07/13 14:16
aaa