DragEnter event issue

I just do drag and drop ZIP file over WPF ListBox.

And after that I am facing that ZIP file is opened. WHY? I didn't asked to open it at all.

Here is my code.

private void lbPackageList_DragEnter(object sender, DragEventArgs e)
{
    bool isCorrect = true;

    if (e.Data.GetDataPresent(DataFormats.FileDrop, true) == true)
    {
        string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop, true);
        foreach (string filename in filenames)
        {
            if (File.Exists(filename) == false)
            {
               isCorrect = false;
               break;
             }
            FileInfo info = new FileInfo(filename);
           if (info.Extension == ".zip") // It's correct
           {
              // OK  
           }
           else
           {
               isCorrect = false;
               break;
           }

     }
   }
   if (isCorrect == true)
        e.Effects = DragDropEffects.All;
   else
         e.Effects = DragDropEffects.None;
            e.Handled = true;
}

Any clues why it is happening? And how do We can stop it?

Answers


WOW

I found the answer

It should be like that

string[] filenames = (string[])e.Data.GetData(DataFormats.FileDrop, false);

Need Your Help

C# Casting types from Interfaces

c# class interface casting

I want to create a set of classes that are very similar and can be cast to each other types. My idea was that I would create an Interface object and implement it through a base class. Then create

Mockito - How to spy on Invocation argument in doAnswer

java unit-testing junit mockito

This is my first day writing Unit tests using Mockito and I might have started with a complex exercise.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.