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();
                }
            }
        }

 

相关文章:

  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-14
  • 2022-12-23
  • 2021-09-06
  • 2021-12-13
  • 2021-08-01
相关资源
相似解决方案