[2005] Drag file onto form and have file name appear in text box
EDIT:
I want to make a simple program to check the files crc to a crc in the file name.
I've changed what I'd like to do with this project. I'd like to be able to select multiple files then drag and drop them into a list box. From there I'm going to run the files through a cmd line crc program to get their crc checksums. Then finally compare the crc in the file name to the crc returned by the crc program. Then show if the file passes or fails the check.
Re: [2005] Drag file onto form and have file name appear in text box
Set AllowDrop on your form to true, then use this:
Code:
Public Class Form1
Private Sub Form1_DragEnter( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.DragEventArgs _
) Handles MyBase.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then _
e.Effect = DragDropEffects.All
End Sub
Private Sub Form1_DragDrop( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.DragEventArgs _
) Handles MyBase.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then _
ListBox1.Items.AddRange(DirectCast(e.Data.GetData(DataFormats.FileDrop), String()))
End Sub
End Class
Re: [2005] Drag file onto form and have file name appear in text box
Re: [2005] Drag file onto form and have file name appear in text box
Thanks MaximilianMayrhofer that works great.
Just one more question for now how can I remove multiple selected lines in the listbox. I've played with ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) and other similar .selected things.
Also how hard would it be to use the del key to del selected item instead of using a button on the form?
Also how can I get the text from a list box line by line. I'm going to have file names dragged into the list box. Then I need to set them in a string that is filename1 filename2 etc. Just a space in between each file name. This is going to be part of the parameters needed to run the cmd line crc checker.
Which reminds me, I have no clue how to run a program with parameter in vb.
here is how i currently run the program.
Code:
Dim info As New System.Diagnostics.ProcessStartInfo(fsum)
info.WindowStyle = ProcessWindowStyle.Minimized
Dim proc As Process = Process.Start(info)
proc.EnableRaisingEvents = True
AddHandler proc.Exited, AddressOf ProcessExited
with fsum as the program name
Re: [2005] Drag file onto form and have file name appear in text box
Quote:
Originally Posted by pball_inuyasha
Thanks MaximilianMayrhofer that works great.
Just one more question for now how can I remove multiple selected lines in the listbox. I've played with ListBox1.Items.RemoveAt(ListBox1.SelectedIndex) and other similar .selected things.
Also how hard would it be to use the del key to del selected item instead of using a button on the form?
Also how can I get the text from a list box line by line. I'm going to have file names dragged into the list box. Then I need to set them in a string that is filename1 filename2 etc. Just a space in between each file name. This is going to be part of the parameters needed to run the cmd line crc checker.
Which reminds me, I have no clue how to run a program with parameter in vb.
here is how i currently run the program.
Code:
Dim info As New System.Diagnostics.ProcessStartInfo(fsum)
info.WindowStyle = ProcessWindowStyle.Minimized
Dim proc As Process = Process.Start(info)
proc.EnableRaisingEvents = True
AddHandler proc.Exited, AddressOf ProcessExited
with fsum as the program name
Use the Listboxes SelectedIndicies collection to get the indicies of the selected items to actually remove those items.