c# 文件拖放进程序获取文件路径

WPF添加Drop事件 Drop="Window_Drop_1"

Winform添加DragDrop事件

        private void Window_Drop_1(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
                e.Effects = DragDropEffects.Link;
            else e.Effects = DragDropEffects.None;
            string _filePath = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
        }



你可能感兴趣的:(C#)