code_junkie

Copy files to clipboard in C#

Nov 11th, 2011
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. StringCollection paths = new StringCollection();
  2. paths.Add("f:\temp\test.txt");
  3. paths.Add("f:\temp\test2.txt");
  4. Clipboard.SetFileDropList(paths);
  5.  
  6. TreeNode selectedNode;
  7. TreeNode copiedNode;
  8.  
  9. selectedNode = yourTreeview.SelectedNode;
  10.  
  11. if (selectedNode != null)
  12. {
  13. copiedNode = selectedNode.Clone;
  14. }
  15.  
  16. // Then you can do whatever you like with copiedNode elsewhere in your app.
  17.  
  18. Clipboard.SetDataObjecT(yourTreeNodeDataObject);
Add Comment
Please, Sign In to add comment