1 回答
TA贡献1770条经验 获得超3个赞
因此,在向专业人士寻求帮助后,我有了一个工作示例。诀窍是让“FileDescriptorW”在自定义 ComObject 类中工作。您将在从 Outlook 拖动示例中找到此类的一个版本,但从 EM 客户端拖动时它不起作用,但确实如此。
然后你可以像这样使用它:
MyDataObject obj = new MyDataObject(e.Data);
string[] fileNames = { };
//ThunderBird Does a FileDrop
if (obj.GetDataPresent(DataFormats.FileDrop, true))
{
string[] tempFileNames = (string[])obj.GetData(DataFormats.FileDrop);
List<string> tempFileNameList = new List<string>();
foreach(string f in tempFileNames)
{
tempFileNameList.Add(Path.GetFileName(f));
}
fileNames = tempFileNameList.ToArray();
} else if (fileNames.Length == 0)
{
//EM Client uses "FileGroupDescriptorW"
fileNames = (string[])obj.GetData("FileGroupDescriptorW");
}else if (fileNames.Length == 0)
{
//Outlook Uses "FileGroupDescriptor"
fileNames = (string[])obj.GetData("FileGroupDescriptor");
}
int index = 0;
foreach (string f in fileNames)
{
File.WriteAllBytes("C:\\FilePath\\"+f, obj.GetData("FileContents", index).ToArray());
index++;
}
- 1 回答
- 0 关注
- 156 浏览
添加回答
举报