Welcome Guest [Log In] [Register]
LOM Traffic Stats
https://youtu.be/whBtH9AnKRo

Join Legends of Modding!



If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply:
[VB.Net] Drag and Drop to Open/Read File(s)
Topic Started: Apr 24 2017, 04:42 PM (375 Views)
The Best
Member Avatar
Your hands are just too short to box with god

It's been a long time since i posted here, so i thought why not posting more tutorials :D
Code:
 
Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
For Each x In files
'This will write the path of the Dragged file to a temp txt file
My.Computer.FileSystem.WriteAllText(My.Computer.FileSystem.SpecialDirectories.Temp & "\Temppath.txt", x, False)

Next
'Reading the same path again to use it.
Dim path As String = My.Computer.FileSystem.ReadAllText(My.Computer.FileSystem.SpecialDirectories.Temp & "\Temppath.txt")
OpenFileDialog1.FileName = path
'Now you can Read/access the file.
'e.g
ReadFile()
End Sub

And then paste this underneath the code above
Code:
 

Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Move
End If

And then finally Set Allowdrop to true in the form settings, and you're done!
Edited by The Best, Apr 24 2017, 04:42 PM.
- - Quote Go To Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Tutorials · Next Topic »
Add Reply:

Black Water created by tiptopolive of the Zetaboards Theme Zone