获取拖进了Windows中的文件的路径表单形式 [英] Get the path of a file dragged into a Windows Forms form

查看:153
本文介绍了获取拖进了Windows中的文件的路径表单形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发需要用户从的Windows&NBSP拖动文件的应用程序;浏览器成应用程序窗口( Windows窗体的形式)。有没有一种方法来读取文件的名称,路径和C#中的文件的其他属性?

I am developing an application which requires the user to drag a file from Windows Explorer into the application window (Windows Forms form). Is there a way to read the file name, path and other properties of the file in C#?

推荐答案

您可以赶上的DragDrop事件,并从那里得到的文件。是这样的:

You can catch the DragDrop event and get the files from there. Something like:

void Form_DragDrop(object sender, DragEventArgs e)
{
    string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);

    //more processing
}

这篇关于获取拖进了Windows中的文件的路径表单形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆