In my Drag and drop Listview i am collecting the dragged and dropped files by:
var objects=Data.GetData(DataFormats.FileDrop, false);
I can also cast this and i get paths of all dragged and dropped files:
string[] DroppedDirectories = (string[])e.Data.GetData(DataFormats.FileDrop, false);
It works fine, but when i drag and drop "MyComputer" or something from Webbrowser, my program throws nullfrefferenceexception.
My question is what is the exact return value of Get data method below (when i drag and drop few files in one moment) ?:
Data.GetData(DataFormats.FileDrop, false);
I assume i have to check every object and eliminate the null ones (then i can cast an array without Null-objects to string [] and i get proper paths and no NRexceptions during further processing).
This code still throws System.NullRefferenceException:
private void Directories_ListView_DragDrop(object sender, DragEventArgs e)
{
object[] rawArray=(object[])e.Data.GetData(DataFormats.FileDrop, false);
foreach (var s in rawArray)\\System.NullRefferenceException occurs..
{
try
{
if (!s.Equals(null))
{
LogList.Items.Add(DateTime.Now + " Item isnt Null");
}
}
catch (Exception)
{
LogList.Items.Add(DateTime.Now + " Item is null");
continue;
}
}