Copy files to clipboard in C#

Consider using the Clipboard class. It features all the methods necessary for putting data on the Windows clipboard and to retrieve data from the Windows clipboard.

StringCollection paths = new StringCollection();
paths.Add("f:\\temp\\test.txt");
paths.Add("f:\\temp\\test2.txt");
Clipboard.SetFileDropList(paths);

The code above will put the files test.txt and test2.txt for copy on the Windows Clipboard. After executing the code you can navigate to any folder and Paste (Ctrl+V) the files. This is equivalent to selecting both files in Windows Explorer and selecting copy (Ctrl+C).

Leave a Comment