Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 拖放;从资源管理器删除我的源文件_C#_Outlook_Vsto - Fatal编程技术网

C# 拖放;从资源管理器删除我的源文件

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

我使用一个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是否捕获丢弃事件

那么我该如何防止这种情况呢


谢谢您的帮助。

好的,我的代码中有一个错误:( 我很遗憾地删除了这个文件


很抱歉打扰您。

请尝试使用
DragDropEffects.Copy
,而不是使用
e.Effect=DragDropEffects.Link,看看这是否解决了我已经尝试过的问题,没有区别:(