views:

30

answers:

1

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
    }
}

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

File.exists(fileName)

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?

+3  A: 

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?

Bill
Basically a graphical interface to a storage repository. If they drop a file, I want to write it to the repository. Dropping a shortcut into the interface would be meaningless in our context.
Brett McCann
Ok, so you probably just want to ignore files with a .lnk extension.
Bill
I see now that .lnk is a reserved extension. If you go to Explorer and create a file giving it a .lnk it automatically becomes a windows shortcut. So I can just check if the file end with .lnk. Thx! Edit: now I see your comment... ;)
Brett McCann