C# WPF Clipboard.SetText() not working properly
Clearing the Clipboard is redundant as SetText does that automatically for you.
This is what I usually use:
Clipboard.SetText(msg, TextDataFormat.Text);
or
Clipboard.SetText(msg,TextDataFormat.UnicodeText);
Reference is here
protected void clipboardSetText(string inTextToCopy)
{
var clipboardThread = new Thread(() => clipBoardThreadWorker(inTextToCopy));
clipboardThread.SetApartmentState(ApartmentState.STA);
clipboardThread.IsBackground = false;
clipboardThread.Start();
}
private void clipBoardThreadWorker(string inTextToCopy)
{
System.Windows.Clipboard.SetText(inTextToCopy);
}