object obj = Clipboard.GetData(DataFormats.FileDrop); if (obj is string[] && (obj as string[]).Length != 0){ }..
using System.IO;
private void button1_Click(object sender, EventArgs e)
{
object obj = Clipboard.GetData(DataFormats.FileDrop);
if (obj is string[] && (obj as string[]).Length != 0)
{
string[] paths = (obj as string[]);//获取复制的图片文件路径(可以复制多个文件)
Clipboard.Clear();//清空剪贴板里的文件列表
foreach (string path in paths)
{
if (File.Exists(path))
{
try
{
using (Bitmap bit = Image.FromFile(path) as Bitmap)
{
Clipboard.SetImage(bit);//将图片添加到剪贴板
}
}
catch (Exception)
{
MessageBox.Show(string.Format("“{0}”不是可用的图片类型!", path));
}
}
richTextBox1.Paste();
}
}
}