WPF 拖动多个文件到窗体 添加文件信息

将WindowAllowDrop属性设置为true

window添加Drop事件

 

private void Window_Drop(object sender, DragEventArgs e)
        {

     string dropFile = "Drop";
            if (e.Data.GetDataPresent(System.Windows.DataFormats.FileDrop))
            {
                int count = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).Length;
                for (int i = 0; i < count; i++)
                {
                    dropFile = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(i).ToString(); ;
                    MessageBox.Show(dropFile);
                }
            }
        }

 

       

posted @ 2016-05-12 11:43  土豆核  阅读(384)  评论(0编辑  收藏  举报