How to determine is there any data stored on the clipboard in C#?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How to determine is there any data stored on the clipboard in C#?
Many thanks for your replying.
 
Hi,
Try this code:
IDataObject d = Clipboard.GetDataObject();

if(d.GetDataPresent(DataFormats.Bitmap))
{
return "Bitmap data on clipboard!!";
}
else if(d.GetDataPresent(DataFormats.Text))
{
return (String)d.GetData(DataFormats.Text);
}
else
{
return "Unknown format of data is Contained on the clipboard.";
}
 
It is very helpful.
Thank you very much.

Manish Bafna said:
Hi,
Try this code:
IDataObject d = Clipboard.GetDataObject();

if(d.GetDataPresent(DataFormats.Bitmap))
{
return "Bitmap data on clipboard!!";
}
else if(d.GetDataPresent(DataFormats.Text))
{
return (String)d.GetData(DataFormats.Text);
}
else
{
return "Unknown format of data is Contained on the clipboard.";
}

--
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
 
Back
Top