How do I copy the contents of a String to the clipboard in C#?

Elie picture Elie · May 22, 2009 · Viewed 171.8k times · Source

If I have some text in a String, how can I copy that to the clipboard so that the user can paste it into another window (for example, from my application to Notepad)?

Answer

ravuya picture ravuya · May 22, 2009

You can use System.Windows.Forms.Clipboard.SetText(...).