How to copy multiple files showing all on the same copying progress dialog

144 Views Asked by At

I've created a multiple drive copier. What happens is that all removable drives are listed in a listbox (lstDrives) then the source of the folder I want to copy to the drives is (txtBrowseFolder.Text)

It loops through the list of drives and copies to each drive. Now my issue is that, since it is a loop, it takes it time to copy one drive after the other, BUT I wish it will copy all at once using the same copying dialog; showing all the copying progress of each item being copied.

Below is my code:

Private Sub cmdCopyDrives_Click(sender As Object, e As EventArgs) Handles cmdCopyDrives.Click
    Dim sDrive As String
    strSource = txtBrowseFolder.Text

    Dim d As Integer

    For d = 0 To lstDrives.Items.Count - 1
        sDrive = lstDrives.Items(d).ToString

        My.Computer.FileSystem.CopyDirectory(strSource, sDrive, FileIO.UIOption.AllDialogs, FileIO.UICancelOption.DoNothing)
    Next
End Sub
1

There are 1 best solutions below

2
On

It does look like it copies all the drives. Unless you mean by "all at once" something other than one code line.

To show progress, use the ProgressBar Control. You know the total number of drives to process (lstDrives.Items.Count) so you can update the bar just before your Next staetment in the For...Next loop.