DragDrop - determine if file or folder

  • Thread starter Thread starter Grant Merwitz
  • Start date Start date
G

Grant Merwitz

Hi

I have an application that allows users to drag files from there desktop
into a TreeView
Now, i'm not sure how to deteremine if they are dragging a file or a folder,
and want to disable dropping of folders

Here is my DragDrop code.
How can i determine is this points to a File or Folder?

TIA

private void tvFoldersFiles_DragDrop(object sender, DragEventArgs e)
{
if(e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop,
false);
for (int i = 0; i < files.Length; ++i)
{
MessageBox.Show(files);
}
}
}
 
Grant Merwitz said:
I have an application that allows users to drag files from there desktop
into a TreeView
Now, i'm not sure how to deteremine if they are dragging a file or a folder,
and want to disable dropping of folders

Here is my DragDrop code.
How can i determine is this points to a File or Folder?

Create a new FileInfo, and then use the Attributes property.
 
Back
Top