0
我想檢查剪貼板是否包含圖像或圖像格式的文件。我想這樣做是這樣的:檢查剪貼板是否包含圖像或文件是圖像
private void myMethod()
{
//Check if the clipboard contains an image or a file, that is in image format.
if (IsClipboardImage())
{
//Do important code
}
else
{
//Do nothing
}
}
private bool IsClipboardImage()
{
if (Clipboard.ContainsImage())
return true;
else if (/* code to check if is an image file? */)
return true;
else
return false;
}
我被告知使用的IDataObject,但使用的是 - 我怎麼會檢查它是否是一個文件,是一個形象?
如果您的right click > copy
圖片來自網絡,但是如果它來自我的文檔,則我的代碼無效。任何幫助,將不勝感激
感謝
嘗試將數據從剪貼板轉換爲'圖像',如果成功,您的數據是圖像 –
但我需要知道如何? – Ben
'Clipboard.GetData()' –