C# 拖放;从资源管理器删除我的源文件
我使用一个Outlook插件,我想从资源管理器将一个文件放到列表框(Outlook区域)中。我只是这样做:C# 拖放;从资源管理器删除我的源文件,c#,outlook,vsto,C#,Outlook,Vsto,我使用一个Outlook插件,我想从资源管理器将一个文件放到列表框(Outlook区域)中。我只是这样做: private void InitializeComponent() { this._shareList.DragDrop += new System.Windows.Forms.DragEventHandler(this._shareList_DragDrop); this._shareList.DragEnter += new System.Windows.Fo
private void InitializeComponent()
{
this._shareList.DragDrop += new System.Windows.Forms.DragEventHandler(this._shareList_DragDrop);
this._shareList.DragEnter += new System.Windows.Forms.DragEventHandler(this._shareList_DragEnter);
}
private void _shareList_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
{
e.Effect = DragDropEffects.Link;
Cursor.Current = Cursors.Arrow;
}
}
private void _shareList_DragDrop(object sender, DragEventArgs e)
{
string[] tab = (string[])e.Data.GetData(DataFormats.FileDrop, false);
foreach (string filePath in tab)
AttachFile(new FileInfo(filePath));
}
当我从资源管理器中删除文件时,源文件将从磁盘中删除!为什么?Outlook是否捕获丢弃事件
那么我该如何防止这种情况呢
谢谢您的帮助。好的,我的代码中有一个错误:( 我很遗憾地删除了这个文件
很抱歉打扰您。请尝试使用
DragDropEffects.Copy
,而不是使用e.Effect=DragDropEffects.Link,看看这是否解决了我已经尝试过的问题,没有区别:(