DragDrop - determine if file or folder

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);
}
}
}
 
J

Jon Skeet [C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top