gpt4 book ai didi

.net - 从 GroupWise 中的电子邮件文件附件拖放到 .NET 应用程序

转载 作者:行者123 更新时间:2023-12-01 04:22:07 28 4
gpt4 key购买 nike

我正在尝试允许将 Novell GroupWise 中打开的电子邮件中的附件放入我的 C# WinForms 应用程序中。标准的 .NET 功能不起作用。

在控件的 DragDrop 事件中,e.Data.GetFormats() 返回以下内容。

FileGroupDescriptorW
FileGroupDescriptor
FileContents
attachment format

我可以使用 e.Data.GetData("FileGroupDescriptor") 获取文件名并转到位置 76。

不幸的是, e.Data.GetData("FileContents") 在 System.Windows.Forms.dll 中导致第一次机会 System.NotImplementedException 并返回 null。附件格式也返回 null。

我的搜索告诉我,拖放比我想象的要复杂得多:) 看起来 GroupWise 可能使用了一种名为 CFSTR_FILECONTENTS 的格式,但这只是一个猜测。附件可以成功拖放到 Windows 桌面或其他文件夹中。

感谢您的任何建议。

最佳答案

我也没有运气找到这个。这是我想出的(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);
}

关于.net - 从 GroupWise 中的电子邮件文件附件拖放到 .NET 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/896197/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com