Quantcast
Channel: Progress Bar e CopyFile
Viewing all articles
Browse latest Browse all 3

Progress Bar e CopyFile

$
0
0

Salve a tutti.Sto creando un'applicazione che permette di copiare una intera directory o un singolo file in un'altra directory.Il codice utilizzato da me è il seguente:

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        OriginalPath = TextBox1.Text
        Destination = TextBox4.Text

        If (Directory = True) And (My.Computer.FileSystem.DirectoryExists(OriginalPath) = True) Then

            My.Computer.FileSystem.CopyDirectory(OriginalPath, Destination)
            MsgBox("Target directory copied!")

        ElseIf (Directory = True) And (My.Computer.FileSystem.DirectoryExists(OriginalPath) = False) Then

            MsgBox("Target directory not found!")

        End If



        If (File = True) And (My.Computer.FileSystem.FileExists(OriginalPath) = True) Then

            My.Computer.FileSystem.CopyFile(OriginalPath, Destination, True)
            MsgBox("Target file copied!")

        ElseIf (File = True) And (My.Computer.FileSystem.FileExists(OriginalPath) = False) Then

            MsgBox("Target file not found!")

        End If
    End Sub

Il primo if riguarda la copia dell'intera directory e il secondo del singolo file. Il codice funziona ma avrei necessità di associarvi anche una progress bar per permettere all'utente di visualizzare lo stato della copia e questo non è possibile grazie alla MsgBox.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images