How can I list clipboard formats

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

object test = Clipboard.GetGata (format);

How can I list the list of formats present on the clipboard?

+3
source share
2 answers
 List<String> dataFormats = typeof(DataFormats).GetFields(BindingFlags.Public | BindingFlags.Static)
                                .Select(f => f.Name)
                                .ToList();

this should give you all the fields from the DataFormats

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

will only give you those that match the buffer.

+1
source

Look at the class IDataObject.

IDataObject content = Clipboard.GetDataObject();
string [] formats = clipContent.GetFormats();
+1
source

All Articles