1个回答
2013-09-02
展开全部
写成这样就行了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();
}
}
}
{
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();
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询