c# - 我正在使用 Clipboard.GetDataObject();但有时它不能像我需要的那样工作

标签 c# clipboard

这是我正在使用的功能

    public String ClipboardGet()
    {
        IDataObject dataObj = Clipboard.GetDataObject();

        if (!dataObj.GetDataPresent(DataFormats.Text))
            return "";

        return dataObj.GetData(DataFormats.Text).ToString();
    }

但有时即使数据是文本,它也会返回一个空字符串,如何处理?

最佳答案

关于c# - 我正在使用 Clipboard.GetDataObject();但有时它不能像我需要的那样工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4266203/

相关文章:

c# - 防止字符串转换为 Null 失败的最佳方法

delphi - 如何检测剪贴板文本更改?

windows - 在不重置剪贴板链的情况下中止进程会导致麻烦吗?

iphone - 通过 UIButton 将文本从 UITextView 复制到剪贴板(粘贴板)?

html - 从 Outlook 复制/粘贴后,剪贴板中的 html 末尾有什么奇怪的字符

java - ClipboardManager 使用 WorkManager 抛出以下错误 : Can't create handler inside thread that has not called Looper. 准备()

c# - WPF 工具提示 : Is there any option to Click on a Button that is inside tooltip (code and picture attached)

c# - 如何使第二级包含对象

c# - LINQ 和 Entity Framework 之间有什么不同?

c# - 如何对这个分层列表进行排序?