Drag Drop from .NET application to Explorer

僤鯓⒐⒋嵵緔 提交于 2019-11-26 17:07:08

问题


I'm looking to provide users with ability to drag&drop files from grids and other controls in my application into Explorer. Any good samples/articles for that?


回答1:


It's pretty straight-forward, just call DoDragDrop in a MouseDown event. You'll need actual files on disk for this to work.

private void Form1_MouseDown(object sender, MouseEventArgs e) { 
   string[] files = new string[] { @"c:\temp\test.txt" };
   this.DoDragDrop(new DataObject(DataFormats.FileDrop, files), DragDropEffects.Copy); 
}



回答2:


Here is a sample application but it cannot handle large files: Transferring Virtual Files to Windows Explorer in C#



来源:https://stackoverflow.com/questions/3398989/drag-drop-from-net-application-to-explorer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!