Pointless Waymarks Software

Software from the Desert Southwest

Dropping Files from Android onto WPF Apps - 1/12/2025

Created and Updated by Charles on 1/12/2025.

My happy feeling of being caught up on a personal project was recently crushed when I realized that dragging a file from my Android phone onto the Pointless Waymarks CMS resulted in ... nothing.

Files on my Windows computer and files from various network shares dropped without issues into the app - and the files from the Android phone worked fine in Windows Explorer between locations - but dragging Android to a WPF app didn't work.

I quickly turned to my buddy GitHub Copilot, who has given me some nice drag-and-drop answers in the past. My buddy produced some code that looked probable - and failed first try (hard to believe that this isn't a standard behavior most people experience these days). In a bit of behavior that might prove that GitHub Copilot is fundamentally human when asked about the exception from its code, the response was to blame the (probably corrupt) incoming data!

I thrashed around for a while looking for different ideas and eventually ended up on a human answer from the depths of Stack Overflow - c# - Dropped zip file causes e.Data.GetData("FileContents") to throw an exception - Stack Overflow (as per usual be sure to read the comments on the answer - the bottom comments will save you some time).

As with many things, it is a little hard to understand why the .NET drag-and-drop abstractions don't help more in this case and leaves you mucking around with FORMATETC and binary formats.

My code based on c# - Dropped zip file causes e.Data.GetData("FileContents") to throw an exception - Stack Overflow (note that I use the GongSolutions.WPF.DragDrop in my WPF projects) can currently be found in the PointlessWaymarksTools Project:


Tags:
Posts Before: