tags:

views:

48

answers:

1

I can't seem to make this work using this:

private void listView1_DragEnter(object sender, DragEventArgs e)
    {
        if (e.Data.GetDataPresent(DataFormats.FileDrop))
        {
            e.Effect = DragDropEffects.Copy;
        }
    }

    private void listView1_DragDrop(object sender, DragEventArgs e)
    {
        string[] directoryName = (string[])e.Data.GetData(DataFormats.FileDrop);
        string[] files = Directory.GetFiles(directoryName[0]);

        foreach (string file in files)
        {
            if (Path.GetExtension(file) == ".mp3")
            {
                listView1.Items.Add(file);
            }
        }
    }

The mouse cursor shows a NOT sign and I can't drop the folder in my program.

+2  A: 

Have you set the AllowDrop property of your ListView to True?

Is your DragEnter event ever being hit?

Dennis Palmer
most probably not setting `listView1.AllowDrop = true;` is the culprit.
TheVillageIdiot