问题描述
我想允许附件从电子邮件中的Novell GroupWise的开放被投进我的C#WinForms应用程序。标准的.NET功能不起作用。
I'm trying to allow an attachment from an email open in Novell GroupWise to be dropped into my C# WinForms application. The standard .NET functionality doesn't work.
在控件的DragDrop事件,e.Data.GetFormats()返回以下。
In the DragDrop event of a control, e.Data.GetFormats() returns the following.
FileGroupDescriptorW
FileGroupDescriptor
FileContents
attachment format
我可以用e.Data.GetData(FileGroupDescriptor)的文件名,并打算76位。
I can get the filename with e.Data.GetData("FileGroupDescriptor") and going to position 76.
不幸的是,e.Data.GetData(FileContents)导致在System.Windows.Forms.dll中第一次机会System.NotImplementedException并返回null。附件格式也将返回null。
Unfortunately, e.Data.GetData("FileContents") causes a first chance System.NotImplementedException in System.Windows.Forms.dll and returns null. Attachment format also returns null.
我的搜索告诉我,拖放是一个复杂得多比我想象:)这似乎是GroupWise的可能使用的格式被称为CFSTR_FILECONTENTS但是这只是一个猜测。附件可以成功拖放到Windows桌面或其他文件夹。
My searches tell me that drag and drop is a lot more complex than I thought :) It seems like GroupWise might be using a format called CFSTR_FILECONTENTS but that's just a guess. The attachments can be successfully dragged and dropped onto the Windows desktop or other folders.
感谢您的任何建议。
推荐答案
我没有运气找到这一点。以下是我想出了(GroupWise的7):
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);
}
这篇关于拖放从电子邮件文件附件GroupWise到.NET应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!