从资源管理器中拖放删除我的源文件
Drag&drop from explorer delete my source file
我在 Outlook 插件上工作,我想从资源管理器中将文件拖放到列表框中(在 outlook 区域中)。我只是这样做:
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 捕捉到 drop 事件?
那我该如何预防呢?
感谢您的帮助。
好的,我的代码出错了:(
不幸的是我删除了文件...
抱歉打扰了。
我在 Outlook 插件上工作,我想从资源管理器中将文件拖放到列表框中(在 outlook 区域中)。我只是这样做:
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 捕捉到 drop 事件?
那我该如何预防呢?
感谢您的帮助。
好的,我的代码出错了:( 不幸的是我删除了文件...
抱歉打扰了。