Cut files to clipboard in C#

前端 未结 3 1500
自闭症患者
自闭症患者 2020-12-06 02:06

I\'m looking for a way to programmatically cut a file to the clipboard, for example, some call to a function in C# that does the same as selecting a file in the Windows Expl

3条回答
  •  半阙折子戏
    2020-12-06 02:38

    Just to see what happens, I replaced the MemoryStream with a DragDropEffects like this:

    data.SetData("FileDrop", files);
    data.SetData("Preferred DropEffect", DragDropEffects.Move);
    

    Apparently, it works as a genuine cut rather than a copy! (This was on Windows 7 - I have not tried other operating systems). Unfortunately, it works only coincidentally. For example,

    data.SetData("Preferred DropEffect", DragDropEffects.Copy);
    

    does not yield a copy (still a cut). It seems that a non-null causes a cut, a null a copy.

提交回复
热议问题