I have problem with copy some text to clipboard. My code looks like this:
using System;
using System.Windows;
namespace namespace
{
public class Class1
{
public void Method1()
{
Clipboard.SetText("some text");
}
}
}
but on line Clipboard.SetText("...");
There is error message
CS0103 The name 'Clipboard' does not exist in the current context
What am I doing wrong?
Clipboard
class is in the PresentationCore
assembly, so you need to add a reference to PresentationCore.dll
and use the appropriate namespace:
System.Windows.Clipboard.SetText("some text");
Or (as you are already doing):
using System.Windows;
.
.
.
Clipboard.SetText("some text");