2013-11-04 86 views
2

我試圖將它從我的C#應用​​程序對Skype的下降的圖像並出現以下錯誤:「錯誤HRESULT E_FAIL已從調用返回至COM組件」:錯誤HRESULT E_FAIL已從調用COM組件返回。 如文字其他應用程序時,Excel工作正常。試圖拖動時和圖像拖放到Skype的C#

     // 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時repproduce相同bahavior Windows資源管理器。有任何想法嗎?

回答

1

當你放下從資源管理器對Skype的圖像,文件被髮送。據我理解你的代碼,你拖動圖像對象,而不是文件。

如果你想從你的文件系統,use this method發送文件。

如果您希望在運行時創建文件而不將其保存到文件系統,則可以實現虛擬文件,如「虛擬文件」部分of this guide中所述。

+0

謝謝您的HELS Soonts,我只是改變了下降的數據和工作! – Andre

+0

不客氣。 – Soonts