Darkmage
Darkmage

Reputation: 1603

I'm using Clipboard.GetDataObject(); but sometimes it does not function like I need

This is the function I'm using

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

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

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

but sometimes it returns a empty string even when the data is text, how to handel this?

Upvotes: 3

Views: 2154

Answers (1)

ordag
ordag

Reputation: 2527

Have you tried Clipboard.GetText or IDataObject.GetDataPresent(string, bool)?

Upvotes: 1

Related Questions