jumper77
Member
I'm trying to copy a folder to the desktop. My code isn't working though. It copies all the files within the folder to the desktop. What do I need to do to make it copy just the directory.
VB.NET:
Private Sub ListView1_DragDrop(sender As Object, e As DragEventArgs) Handles ListView1.DragDrop
Dim files() As String = CType(e.Data.GetData(DataFormats.FileDrop), String())
For Each item In files
If Directory.Exists(Path.Combine(CStr(item), DesktopPath & "\")) Then
'copies all the files within directory, but not the folder itself
My.Computer.FileSystem.CopyDirectory(CStr(item), DesktopPath)
Else
File.Copy(CStr(item), Path.Combine(DesktopPath, Path.GetFileName(CStr(item))))
End If
Next
End Sub