C# winform实现文件拖拽功能

private void txtAppPath_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Link;
}
else
{
e.Effect = DragDropEffects.None;
}
}

    private void txtAppPath_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
    {
        txtLocalFileName.Text = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
    }
C# winform实现文件拖拽功能_第1张图片
QQ截图20181224145131.png
C# winform实现文件拖拽功能_第2张图片
QQ截图20181224145237.png

你可能感兴趣的:(C# winform实现文件拖拽功能)