Skip to content

Instantly share code, notes, and snippets.

@taka2
Created December 1, 2009 09:02
Show Gist options
  • Select an option

  • Save taka2/246174 to your computer and use it in GitHub Desktop.

Select an option

Save taka2/246174 to your computer and use it in GitHub Desktop.
using System;
using System.Windows.Forms;
public class Form1 : Form
{
public Form1()
{
this.AllowDrop = true;
this.DragEnter += new System.Windows.Forms.DragEventHandler(this.button1_DragEnter);
this.DragDrop += new System.Windows.Forms.DragEventHandler(this.button1_DragDrop);
}
private void button1_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
private void button1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
string[] s = (string[]) e.Data.GetData(DataFormats.FileDrop, false);
foreach(string str in s)
MessageBox.Show(str);
}
[STAThread]
static void Main(string[] args)
{
Application.Run(new Form1());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment