I'm implementing the Drag Files function to populate a Listbox with the path of the files.
It works fine, but I would like to put a "filter" making it possible only txt to be imported.
If it is not txt, an Error MessageBox should appear to the user.
Follow the Code
private void listBoxArquivosSelecionados_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Link;
else
e.Effect = DragDropEffects.None;
}
private void listBoxArquivosSelecionados_DragDrop(object sender, DragEventArgs e)
{
string[] arquivos = e.Data.GetData(DataFormats.FileDrop) as string[];
if (arquivos != null)
listBoxArquivosSelecionados.Items.AddRange(arquivos);
CarregarStatus();
}