标签:
/// <summary> /// 窗体加载的时候,设置可以允许文件拖放 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_Load(object sender, EventArgs e) { //设置允许拖放属性 this.AllowDrop = true; } /// <summary> /// 把文件拖到窗体时候发生的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Form1_DragEnter(object sender, DragEventArgs e) { //获取拖放数据 if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] content = (string[])e.Data.GetData(DataFormats.FileDrop); for (int i = 0; i < content.Length; i++) { //这是全路径 label1.Text += content[i]; } } }
标签:
原文地址:http://www.cnblogs.com/baixdu/p/4944720.html