2
votes

I want to copy object ( List ) to clipboard and use it in my application and outside of it. In my application, I want to be able to "paste" data without any additional operation. Outside I need CSV data.

I tried to achieve it by using DataObject. I can convert this list to formatted string - so i think it's easy to get CSV. I stored random string in DataObject, (just for test). The problem is storing List object in Clipboard. DataObject contains specific type ( checked using DataObject.GetFormats() ), but when i try to get this object from clipboard, I get null.

I've found this, while it solves my problem, I need to serialize/deserialize.

Is there any way to store and retrieve object the normal way ?

1
Program you are trying to paste your data into doesn't know structure of the object being pasted, thus it doesn't know what to do with it. To copy to CSV file you need properly formatted string so serializing is the best way to do it.slawekwin

1 Answers

1
votes
Clipboard.SetDataObject(list);
var deslist = Clipboard.GetDataObject().GetData(list.GetType());