[英]Why Clipboard.SetText doesn't work?
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("...");
但是在线
Clipboard.SetText("...");
There is error message 有错误信息
CS0103 The name 'Clipboard' does not exist in the current context
CS0103当前上下文中不存在名称“剪贴板”
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: Clipboard
类位于PresentationCore
程序集中,因此您需要添加对PresentationCore.dll
的引用并使用适当的名称空间:
System.Windows.Clipboard.SetText("some text");
Or (as you are already doing): 或者(正如您已经在做的那样):
using System.Windows;
.
.
.
Clipboard.SetText("some text");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.