To copy a text or a image to the windows clipboard you can use the following snippet.
Sample C#
public void CopyToClipboard(string input, bool keepAlive) { System.Windows.Forms.Clipboard.SetDataObject(input, keepAlive); } public void CopyToClipboard(Image img, bool keepAlive) { System.Windows.Forms.Clipboard.SetDataObject(img, keepAlive); }
Sample VB.NET
Public Sub CopyToClipboard(input As String, keepAlive As Boolean) System.Windows.Forms.Clipboard.SetDataObject(input, keepAlive) End Sub Public Sub CopyToClipboard(img As Image, keepAlive As Boolean) System.Windows.Forms.Clipboard.SetDataObject(img, keepAlive) End Sub
for more informations see the MSDN Clipboard.SetDataObject Method
RT @CodeSnippetsNET: How to copy to the windows clipboard: http://t.co/pKDga9fvDZ #csharp #dotnet