Jonathan, I imagine you want to get the address from the file. Well, for this you need to do a check if what is being dragged is in fact a file with the Dragover Event
private void TextBox_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Link;
else
e.Effect = DragDropEffects.None;
}
Then when the file is released inside the Textbox (Dragdrop Event) you create a string with the file
private void TextBox_DragDrop(object sender, DragEventArgs e)
{
string arquivo = e.Data.GetData(DataFormats.FileDrop) as string;
TextBox.Text = arquivo;
}
In short it’s good luck.
Source:
http://www.andrealveslima.com.br/blog/index.php/2015/03/11/implementando-drag-and-drop-arrastar-e-soltar-em-aplicacoes-windows-forms-com-c/
I wanted to drag you into one
TextBox
and show the contents of the file?– rubStackOverflow
For a Listbox, however, it is a complete file, in format . txt.
– Jonathan Barcela
It is a file with data to fill a
ListBox
? Or you want to fill only with the file name? If you want to fill in the contents ofListBox
add the contents of the file to question.– rubStackOverflow
Simply read the file to the end and play line by line in Listbox.
– Jonathan Barcela
@Jonathanbarcela In general lines you want to put in a listbox the name of the text file and the number of lines it has. See if you can get help https://msdn.microsoft.com/pt-br/library/ezwyzy7b.aspx
– Luiz Vichiatto