Copy empty string using Clipboard.SetText(string)

If you try to save null or an empty string using Clipboard.SetText it will never work.

See Clipboard.SetText Method (String) (MSDN). It mentions ArgumentNullException is thrown if the text is null or Empty for Clipboard.SetText.

Hence you cannot achieve what you are trying to achieve.


I think you need to do

Clipboard.Clear()

From MSDN

Clears any data from the system Clipboard.


See Clipboard.Clear Method (System.Windows.Forms) (MSDN).

Clipboard.Clear();

will clear the clipboard, so you will "paste" an empty string.

Tags:

C#

Clipboard