Worf
06-22-2010, 07:07 AM
Hi.
I have managed to list folders in my listbox1 and the add them to listbox 2.
Now, what i need now is to be able to copy the list of folder in listbox2 to another location.
below is the code i am using.
Browse drive and and fill listbox1 with the folders on that drive.
Path.text hold the path to where the folders.
If FolderBrowserDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
Path.Text = FolderBrowserDialog.SelectedPath
Dim Dirs As New List(Of String)
Try
Dirs.AddRange(My.Computer.FileSystem.GetDirectories(Path.Text))
ListBox1.BeginUpdate()
For Each str As String In Dirs
ListBox1.Items.Add(My.Computer.FileSystem.GetDirectoryInfo(str).Name)
ListBox1.EndUpdate()
' Remove Duplicate items
For ii As Integer = ListBox1.Items.Count - 1 To 1 Step -1
For j As Integer = ii - 1 To 0 Step -1
If ListBox1.GetItemText(ListBox1.Items(ii)) _
= ListBox1.GetItemText(ListBox1.Items(j)) Then
ListBox1.Items.RemoveAt(ii)
Exit For
End If
Next j
Next ii
If String.IsNullOrEmpty(str) Then
MsgBox("Error")
Exit Sub
End If
Next
Catch ioex As System.UnauthorizedAccessException
Catch ex As Exception
Return
End Try
End If
I just need to know how to copy the folder that are listed in listbox2 to another location.
Many Thanks
Worf
I have managed to list folders in my listbox1 and the add them to listbox 2.
Now, what i need now is to be able to copy the list of folder in listbox2 to another location.
below is the code i am using.
Browse drive and and fill listbox1 with the folders on that drive.
Path.text hold the path to where the folders.
If FolderBrowserDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
Path.Text = FolderBrowserDialog.SelectedPath
Dim Dirs As New List(Of String)
Try
Dirs.AddRange(My.Computer.FileSystem.GetDirectories(Path.Text))
ListBox1.BeginUpdate()
For Each str As String In Dirs
ListBox1.Items.Add(My.Computer.FileSystem.GetDirectoryInfo(str).Name)
ListBox1.EndUpdate()
' Remove Duplicate items
For ii As Integer = ListBox1.Items.Count - 1 To 1 Step -1
For j As Integer = ii - 1 To 0 Step -1
If ListBox1.GetItemText(ListBox1.Items(ii)) _
= ListBox1.GetItemText(ListBox1.Items(j)) Then
ListBox1.Items.RemoveAt(ii)
Exit For
End If
Next j
Next ii
If String.IsNullOrEmpty(str) Then
MsgBox("Error")
Exit Sub
End If
Next
Catch ioex As System.UnauthorizedAccessException
Catch ex As Exception
Return
End Try
End If
I just need to know how to copy the folder that are listed in listbox2 to another location.
Many Thanks
Worf