0

I have a application, in which user can drag & drop files from any folder and also can d&d emails or email attachments from outlook application.

When drag event fires, I will operate with DragEventArgs, where args.Data is a (System.Windows) DataObject (our dragged object).

To simplify the task, we can drag only one file.

I do not need to determine the place where the d&d occurred, I should prohibit d&d files that are not .msg or .eml formats.

Remark: If user d&d a file from any folder I will get the file path through:

args.Data.GetData(DataFormats.FileDrop)

But when user d&d any data from outlook, that can be attachment or the whole email

args.Data.GetData(DataFormats.FileDrop) is null

Thanks for help!

Uladzimir Sharyi
  • 144
  • 1
  • 14
  • 2
    See https://stackoverflow.com/questions/17184369/upload-fails-when-user-drags-and-drops-attachment-from-email-client/17197224#17197224 – Dmitry Streblechenko Apr 13 '18 at 16:56
  • Please don't spam random unrelated tags. This is very obviously not a `C` question. A [C programmer might react to this question in unpredictable ways](https://dakiniland.files.wordpress.com/2012/01/2001-a-space-odyssey-ape-monolith.jpg). – 15ee8f99-57ff-4f92-890c-b56153 Apr 13 '18 at 17:53
  • @DmitryStreblechenko, thanks it might be helpful! – Uladzimir Sharyi Apr 13 '18 at 18:17
  • @EdPlunkett, where did you see unrelated tags? Probably only wpf tag, but the application which was described is based on wpf. – Uladzimir Sharyi Apr 13 '18 at 18:21
  • @SharyUladzimir Look at the edit history. It was tagged as C. I fixed it. WPF isn't relevant to the code you're asking about, but at least it *is* a WPF project. – 15ee8f99-57ff-4f92-890c-b56153 Apr 13 '18 at 18:21
  • 1
    Anyway the answer to your question is call `GetFormats()` on the dataobject, see what's in there. Try testing each kind of object you want to be able to drop on the application. Set a breakpoint in your drop handler, have a loop that grabs the data for each format as `object`, and inspect each one in the debugger. Find out what formats have what you want. You'll find some kind of pattern whereby your code can figure out what the user did. – 15ee8f99-57ff-4f92-890c-b56153 Apr 13 '18 at 18:37
  • @EdPlunkett, ok, i agree about wpf, but why outlook tag was removed? if i hadn't added it, probably Dmitry wouldn't have given me advise. it's not the first time I've been given advice related to the outlook from him. And the issue is directly related to the outlook. – Uladzimir Sharyi Apr 13 '18 at 18:38
  • @SharyUladzimir Good point, I put that back. – 15ee8f99-57ff-4f92-890c-b56153 Apr 13 '18 at 18:38
  • @EdPlunkett, thanks a lot! I thought and tested GetFormats() but it is a very unreliable and fragile solution. – Uladzimir Sharyi Apr 13 '18 at 18:45
  • @SharyUladzimir How did you find it to be fragile and unreliable? Do different versions of Outlook behave differently (it wouldn't surprise me a bit if they do). – 15ee8f99-57ff-4f92-890c-b56153 Apr 13 '18 at 18:46
  • @EdPlunkett,i mean, when you drop email from outlook, GetFormats() will return you a huge amount (around 15) of different formats. And among them will be formats, that GetFormats() will return you, if you drop .txt for example. It is difficult to find some specific pattern, because user can drop file with any format, or as the next issue user can drop not only one file. And GetFormats() will return intersection. – Uladzimir Sharyi Apr 13 '18 at 19:03
  • Yeah, 14 different formats. So if you can't find documentation, look at them in the debugger and figure it out. That's what you're paid for. – 15ee8f99-57ff-4f92-890c-b56153 Apr 13 '18 at 19:16
  • @EdPlunkett, Thank you for the help! – Uladzimir Sharyi Apr 13 '18 at 19:18
  • A utility like ClipSpy would be perfect to look at all the available formats and their data. – Dmitry Streblechenko Apr 13 '18 at 22:21

0 Answers0