如何在C#拖放操作中分辨文件中的快捷方式? [英] How can I tell a shortcut from a file in a C# drag and drop operation?

查看:104
本文介绍了如何在C#拖放操作中分辨文件中的快捷方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C#.NET 3.5应用程序,已将DragDrop事件合并到DataGridView中。

I have a C# .NET 3.5 app that I have incorporated the DragDrop event on a DataGridView.

#region File Browser - Drag and Drop Ops
private void dataGridView_fileListing_DragDrop(object sender, DragEventArgs e)
{
    string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
    foreach (string fileName in fileList)
    {
       //logic goes here
    }
}

我的问题是,如何区分Windows快捷方式和实际文件?我试过了:

My question is, how can I differentiate a windows shortcut from an actual file? I tried:

File.exists(fileName)

在IF块中,它有助于过滤出已拖入的目录,但是快捷方式可以通过。无论如何,是否有办法告诉事件数据传递的数据中是否有快捷方式,或者一旦我有了名字便通过查询文件系统来实现?

in an IF block which is useful to filter out directories that have been dragged in, however shortcuts get through. Is there anyway on to tell a shortcut in the data passed in by the event data, or by querying the file system once I have the name?

推荐答案

Windows快捷方式是一个文件,扩展名为.lnk。

A Windows shortcut is a file, just with a .lnk extension.

您能否详细说明您希望使用或不使用它?

Could you elaborate more about what you hope to do or not do with it?

这篇关于如何在C#拖放操作中分辨文件中的快捷方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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