0

In .NET, is it possible to get the clipboard contents regardless of format, hold them in memory and then later restore them?

I tried Clipboard.GetDataObject() but it seems impossible to restore this value without knowing the format. I would ideally like to:

var list = new List<object>();
...
list.Add(Clipboard.GetData());
... later ...
Clipboard.SetData(list[x]);
user826840
  • 1,233
  • 2
  • 13
  • 28
  • Cant you call GetDataObject and to set the data, loop through all objects using the format list and call SetData multiple times? – Rico Suter Aug 18 '14 at 12:40

1 Answers1

0

It is impossible because of one reason: you just don't know what user will put in clipboard during activity. The only way is to try which format of data is in cliboard using DataFormats Class

Piotr Stapp
  • 19,392
  • 11
  • 68
  • 116
  • That's a shame. A appreciate I would need to know the format to use/interact with the data, but just to store it for a few minutes and then restore it to the clipboard? – user826840 Aug 18 '14 at 12:25
  • Why you don't store data on disk? You could use app data folder(see more: http://stackoverflow.com/questions/867485/c-sharp-getting-the-path-of-appdata) Also temp folder should be a good idea. – Piotr Stapp Aug 18 '14 at 12:27