Link to home
Start Free TrialLog in
Avatar of codefinger
codefingerFlag for United States of America

asked on

recognizing a file drop from Groupwise

I want the users to be able to open a Groupwise email and drag a file attachment on to a list box in my winforms application.  The application recognizes what has happened and takes possession of the file, or a copy of it, for further processing.

How can this be done?

Thanks.
Avatar of Scott Kunau
Scott Kunau
Flag of United States of America image

I just opened a GroupWise message with an .xls file attachment and dragged it to my desktop.  Then I double-clicked on it and it opened just fine.

I'm not sure what you mean by "list box in my winforms application".  Perhaps you have a screen capture of the list box?

Scott
Avatar of codefinger

ASKER

By "list box in my winforms application", I mean the application I am coding.

According to my Googling, the code attached below MAY do what I need, but it is in VC.Net where I have no skill.   If some one could re-write it in VB.NET,  and it works, that will be my solution.

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); 
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of codefinger
codefinger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial