现在的位置: 首页 > 综合 > 正文

c#中实现文件拖放打开的方法

2013年10月16日 ⁄ 综合 ⁄ 共 391字 ⁄ 字号 评论关闭
Copy code

private void Form1_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 Form1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{

//其中label1.Text显示的就是拖进文件的文件名;

label1.Text = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();

}

抱歉!评论已关闭.