How do I drag and drop files into an application?

Some sample code: public partial class Form1 : Form { public Form1() { InitializeComponent(); this.AllowDrop = true; this.DragEnter += new DragEventHandler(Form1_DragEnter); this.DragDrop += new DragEventHandler(Form1_DragDrop); } void Form1_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; } void Form1_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); foreach (string file in files) Console.WriteLine(file); } … Read more

HTML5 dragleave fired when hovering a child element

You just need to keep a reference counter, increment it when you get a dragenter, decrement when you get a dragleave. When the counter is at 0 – remove the class. var counter = 0; $(‘#drop’).bind({ dragenter: function(ev) { ev.preventDefault(); // needed for IE counter++; $(this).addClass(‘red’); }, dragleave: function() { counter–; if (counter === 0) … Read more