This is a reminder to myself about what data is available when you drag-drop Windows Explorer files or folders onto a WPF control. I used this code to intercept and dump the Drop event:
private void ListBox_Drop(object sender, DragEventArgs e)
{
foreach (string format in e.Data.GetFormats())
{
Trace.Write(format.PadLeft(22) + " ");
object o = e.Data.GetData(format);
if (o is string[])
{
Trace.WriteLine(string.Join(" + ", (string[])o));
}
else if (o is MemoryStream)
{
var ms = (MemoryStream)o;
byte[] buff = new byte[ms.Length];
ms.Read(buff, 0, (int)ms.Length);
Trace.WriteLine(string.Format("[{0}]{1}",
buff.Length,
BitConverter.ToString(buff, 0, Math.Min(1024, buff.Length)).Replace("-", "")));
}
else
{
Trace.WriteLine(string.Format("Other {0}", o));
}
}
}
The number of formats is unpredictable and seems to depend upon whether you drop one or more objects, or if they have long names or not. I dropped three long name files and found this data (truncated):
Shell IDList Array [549]0300000014000000A7000000230100008F01000014001F50E04FD020EA…
UsingDefaultDragImage [4]01000000
DragImageBits [36896]60000000600000003000000059000000BD0C05D000000000FFFFFFFF…
DragContext [16]00000000010000000000000000000000
DragSourceHelperFlags [4]01000000
InShellDragLoop [4]00000000
FileDrop K:\dev_experiments\sk-security-tiers.nuspec + K:\dev_experiment…
FileNameW K:\dev_experiments\sk-security-tiers.nuspec
FileName K:\DEV_EX~1\SK-SEC~1.NUS
IsShowingLayered [4]00000000
DragWindow [4]10042200
IsComputingImage [4]00000000
DropDescription [1044]FFFFFFFF0000000000000000000000000000000000000000000000000…
DisableDragText [4]01000000
IsShowingText [4]00000000
ComputedDragImage [4]BD0C05D0


