Leggere i possibili formati di lettura in clipboard:

  1. private string GetFormatsInClipboard()
  2. {
  3.     StringBuilder sb = new StringBuilder();
  4.     IDataObject dataClipboard = Clipboard.GetDataObject();
  5.     if ((dataClipboard != null))
  6.     {
  7.         foreach (string item in dataClipboard.GetFormats(true))
  8.         {
  9.             sb.AppendFormat("{0}\r\n", item);
  10.         }
  11.     }
  12.     return sb.ToString();
  13. }
  14.  

 

Drag&Drop di un file in una TextBox per averne il path:

  1. private void txtPathFile_DragEnter(object sender, DragEventArgs e)
  2. {
  3.     if (e.Data.GetDataPresent(DataFormats.FileDrop))
  4.         e.Effect = DragDropEffects.Copy;
  5.     else
  6.         e.Effect = DragDropEffects.None;
  7.  
  8. }
  9. private void txtPathFile_DragDrop(object sender, DragEventArgs e)
  10. {
  11.     string[] FileList = (string[])e.Data.GetData(DataFormats.FileDrop, false);
  12.  
  13.     if (FileList != null && FileList.Length > 0)
  14.         txtPathFile.Text = FileList[0];
  15. }
  16.