我正在尝试将图像从我的C#应用程序拖放到Skype,并发生以下错误:错误HRESULT E_FAIL已从调用COM组件返回。 使用Word等其他应用程序,Excel工作正常。
// Find the data behind the ListViewItem
DashboardItem item = (DashboardItem)listView.ItemContainerGenerator.
ItemFromContainer(listViewItem);
DragDropEffects returnedEffect = DragDropEffects.None;
dragging = true;
switch (item.Type)
{
case DashboardItem.ContentType.IMG:
BitmapSource realFile = new BitmapImage(new Uri(item.Content));
if (realFile != null)
{
using (MemoryStream bitmapAsStream = Utils.BitmapSourceToStream(realFile))
{
if (bitmapAsStream != null)
{
using (MemoryStream dib = new MemoryStream())
{
dib.Write(bitmapAsStream.GetBuffer(), 14, (int)(bitmapAsStream.Length - 14));
DataObject dragData = new DataObject(DataFormats.Dib, dib);
//Error next line
returnedEffect = DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Copy);
bitmapAsStream.Close();
dib.Close();
}
}
}
}
}
break;
我想在将图像丢弃到Skype时重新生成与Windows资源管理器相同的行为。有什么想法吗?
答案 0 :(得分:1)
将图像从资源管理器拖放到Skype时,正在发送文件。据我了解你的代码,你是拖动一个图像对象,而不是文件。
如果您想从文件系统发送文件use this method。
但是,如果您想在运行时创建文件而不将其保存到文件系统,则可以实现虚拟文件,如“虚拟文件”部分of this guide中所述。