3

With WPF, I can get data in a given format from the clipboard:

object test = Clipboard.GetGata (format);

How can I enumerate the list of formats present in the clipboard?

user380719
  • 9,663
  • 15
  • 54
  • 89

2 Answers2

2

Have a look at the IDataObject class.

IDataObject content = Clipboard.GetDataObject();
string [] formats = clipContent.GetFormats();
Jf Beaulac
  • 5,206
  • 1
  • 25
  • 46
1
 List<String> dataFormats = typeof(DataFormats).GetFields(BindingFlags.Public | BindingFlags.Static)
                                .Select(f => f.Name)
                                .ToList();

this should give you all the Fields from DataFormats

List<String> dataFormatsInClipboard = 
             dataFormats.Where( df => Clipboard.ContainsData(df) )
             .ToList();

will give you just the ones that match the clipboard.

Bala R
  • 107,317
  • 23
  • 199
  • 210