How to drag and drop image from wpf application to uwp application?

laxmi swami 1 Reputation point
2020-06-23T07:19:38.713+00:00

I am trying to drag an image from WPF application to UWP application but getting this error "invalid formatetc structure (exception from hresult: 0x80040064 (dv_e_formatetc)) in GetStorageItemsAsync method"

(This code is working when I drag a file from windows explorer but throws an exception when I drag an image from another application)

public async void OnFileDrop(object sender, DragEventArgs e)
{
List<StorageFile> dropFiles = new List<StorageFile>();
if (e.DataView.Contains(StandardDataFormats.StorageItems))
{
var items = await e.DataView.GetStorageItemsAsync();
var isShow2GBMessage = false;
var isShowEXEerrorMessage = false;
if (items.Count > 0)
{
foreach (var appFile in items.OfType<StorageFile>())
{
BasicProperties filesize = await appFile.GetBasicPropertiesAsync();
var fileSize = filesize.Size;
CheckAndAddFiles(dropFiles, ref isShow2GBMessage, ref isShowEXEerrorMessage, appFile, fileSize);
}
}
UploadFiles(dropFiles);
}
}
When I drag the image it is getting copied into a folder but how do I get the path using DragEventArgs?

Universal Windows Platform (UWP)
{count} votes