The user right clicks on a file(say on the desktop) and clicks 'copy' . Now how do I determine in C# if the file copied to the clipboard is an image type ?
Clipboard.ContainsImage() doesn't work in this case
The following determines if an image is directly copied to the clipboard, not if a file is copied to the clipboard
IDataObject d = Clipboard.GetDataObject();
if(d.GetDataPresent(DataFormats.Bitmap))
{
MessageBox.Show("image file found");
}
To be clear I want to determine if the 'file' copied to the clipboard is an image.
Edit: the answers are great, but how do I get the filename of a file copied to the clipboard ? Clipboard.getText() doesn't seem to work.. Edit2: Clipboard.GetFileDropList() works
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…