我有一个关于在 wpf 应用程序上删除电子邮件(eml 文件)的问题。我的问题是我的应用程序存储了 eml 文件,但如果我打开它,我的 Tobit 电子邮件客户端会显示一个空邮件。放在桌面上并打开它完美无缺。就像图像或文本文件等其他文件也可以工作一样。
谢谢你的每一个帮助。
这是我的代码:
private void listViewDocumentsSA_Drop(object sender, DragEventArgs e)...
string[] format = e.Data.GetFormats();
System.Windows.DataObject obj = (System.Windows.DataObject)e.Data;
Object item = (object)e.Data.GetData(typeof(System.String));
try
{
string[] fileNames = null;
string dir = System.Configuration.ConfigurationSettings.AppSettings["dir"];
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
string filename = "";
if (e.Data is System.Windows.DataObject && ((System.Windows.DataObject)e.Data).ContainsFileDropList())
{
foreach (string filePath in ((System.Windows.DataObject)e.Data).GetFileDropList())
{
filename = dir + "test" + "$" + System.DateTime.Now.Ticks.ToString() + "$" + System.IO.Path.GetFileName(filePath);
filename = filename.Replace("\\\\", "\\");
File.Copy(filePath, filename, false);
}
}
if (e.Data.GetDataPresent("FileGroupDescriptor"))
{
Stream theStream = (Stream)e.Data.GetData("FileGroupDescriptor");
byte[] fileGroupDescriptor = new byte[512];
theStream.Read(fileGroupDescriptor, 0, 512);
StringBuilder fileName = new StringBuilder("");
for (int i = 76; fileGroupDescriptor[i] != 0; i++)
{
fileName.Append(Convert.ToChar(fileGroupDescriptor[i]));
}
theStream.Close();
string path = dir + "test" + "$" + System.DateTime.Now.Ticks.ToString() + "$";
path = path.Replace("\\\\", "\\");
string theFile = path + fileName.ToString();
if (e.Data.GetDataPresent("FileContents", false))
{
string[] formats = e.Data.GetFormats();
MemoryStream ms = e.Data.GetData("FileGroupDescriptorW") as MemoryStream;
byte[] fileBytes = new byte[ms.Length];
ms.Position = 0;
ms.Read(fileBytes, 0, (int)ms.Length);
FileStream fs = new FileStream(theFile, FileMode.Create);
fs.Write(fileBytes, 0, (int)fileBytes.Length);
fs.Close();
}
else
throw new System.Exception("...");
}
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}