Drag and drop from an email file attachment in GroupWise to a .NET application

帅比萌擦擦* 提交于 2019-12-05 15:40:26

I had no luck finding this too. Here is what I came up with (Groupwise 7):

private void control_DragDrop(object sender, DragEventArgs e)
{
   string strFilename = null;

   //something about the act of reading this stream creates the file in your temp folder(?)
   using (MemoryStream stream = (MemoryStream)e.Data.GetData("attachment format", true))
   {
       byte[] b = new byte[stream.Length];
       stream.Read(b, 0, (int)stream.Length);
       strFilename = Encoding.Unicode.GetString(b);
       //The path/filename is at position 10.
       strFilename = strFilename.Substring(10, strFilename.IndexOf('\0', 10) - 10);
       stream.Close();
   }

   if (strFilename != null && File.Exists(strFilename))
   {
      //From here on out, you're just reading another file from the disk...
      using(FileStream fileIn = File.Open(strFilename, FileMode.Open))
      {
          //Do your thing
          fileIn.Close();
      }
   }

   File.Delete(strFilename);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!