and provides that link that you should follow. I would suggest that you work through that to understand the principles involved first. I would then try coding both the drag and drop operations using the file path in your own application to make sure that the drop end is getting the correct data. You should then be able to just do the drag part in your app and the drop part will work in File Explorer.Additionally, you can configure your TextBox control to allow text strings to be dragged and dropped into WordPad. For more information, see Walkthrough: Performing a Drag-and-Drop Operation in Windows Forms.
Text
or the like when you probably need to use FileDrop
. I would suggest that you do the same drag and drop into your app from File Explorer that you do to the other app and see what data formats are available and then make sure that those same formats are available when you drag from your app.Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
Dim data As New DataObject()
Dim filePaths As New StringCollection
filePaths.Add(Path.Combine(Application.StartupPath, "TestData.txt"))
data.SetFileDropList(filePaths)
DoDragDrop(data, DragDropEffects.Copy)
End Sub
DoDragDrop
and look for that same type when dropping. If you're doing it between applications then you do as I have here, i.e. create a DataObject
, add data to it in the appropriate format(s) and then pass that to DoDragDrop
. That will ensure that any application that supports drag and drop between applications will be able to access that data in the appropriate standard format.DataObject
class also has SetText
, SetImage
and SetAudio
methods for specific data types and a SetData
method for everything else. They are the complementary methods to the e.Data.GetX
methods you call in a DragDrop
event handler.DataObject
into DoDragDrop
(probably it would be more accurate to say anything that doesn't implement IDataObject
) then it will be wrapped in a DataObject
anyway, so you will always get that back when you drop. If you were to just pass in a String
then I would guess that that would be the same as doing what I did above but calling SetText
and passing that String
instead of calling SetFileDropList
. If you don't specify the FileDrop
data format then the receiving application will just treat it as any old text rather than the path of a file/folder, so it won't consider it to represent a file to copy/move.