Created
December 1, 2009 09:02
-
-
Save taka2/246174 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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