Hello, I am new here, and I apologize firstly if this is in the wrong section or topic, but this seemed like the correct place.
I have a windows form, with basically four "instances" of a Control, two buttons and a picture box. The picture box shows the icon of a folder chosen by the user, the buttons open the folder in windows explorer and allow the user to choose a new folder.
The control. I have attempted this with a panel, picture box and a listview, all with AllowDrop set to true.
ListView1 = ListView control
RemovePathSizeGet....RemovePath(Path As String) returns the name of the file from the path, by seperateing the path by "\" and returning the last part (Name).
Box2Path = String containing full path of a folder not ending in "\"
My code for the drop events are below:
I have probably made a fairly obvious mistake, but it escapes me.
When I drop a file onto it, from any location, it simply shows the message box "Could not copy the selected files. See help."
Any help is very much appreciated ^^ And sorry this is my first post, but it's the first time I've not been able to find an answer by searching through google and the websites it throws up.
I have a windows form, with basically four "instances" of a Control, two buttons and a picture box. The picture box shows the icon of a folder chosen by the user, the buttons open the folder in windows explorer and allow the user to choose a new folder.
The control. I have attempted this with a panel, picture box and a listview, all with AllowDrop set to true.
ListView1 = ListView control
RemovePathSizeGet....RemovePath(Path As String) returns the name of the file from the path, by seperateing the path by "\" and returning the last part (Name).
Box2Path = String containing full path of a folder not ending in "\"
My code for the drop events are below:
VB.NET:
Private Sub ListView1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragDrop
Try
'Retrieve the data in the array format.
'Add the dragged items to the PATH
Dim FileToCopy As String
Dim NewCopy As String
Dim FileName As String
FileToCopy = e.Data.GetData(DataFormats.FileDrop)
FileName = RemovePathGetSizeTwo.PathRemove.RemovePath(FileToCopy)
NewCopy = Box2Path + FileName
If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)
MsgBox("File Copied")
End If
Catch
MsgBox("Could not copy the selected files. See help.")
End Try
End Sub
Private Sub ListView1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListView1.DragEnter
Try
'Check for the DataFormat 'FileDrop'
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
'set the Effect of drag-and-drop operation to Copy (adds a '+')
e.Effect = DragDropEffects.Copy
Else
'Else set the Effect of drag-and-drop operation to None
e.Effect = DragDropEffects.None
End If
Catch
MsgBox("That isn't a valid file.")
End Try
End Sub
I have probably made a fairly obvious mistake, but it escapes me.
When I drop a file onto it, from any location, it simply shows the message box "Could not copy the selected files. See help."
Any help is very much appreciated ^^ And sorry this is my first post, but it's the first time I've not been able to find an answer by searching through google and the websites it throws up.
Last edited: