private void FmMain_DragDrop(object sender, DragEventArgs e)
{
//检测是否是windows格式
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
//获取拖放的文件列表
string[] paths = (string[])e.Data.GetData(DataFormats.FileDrop);
FileInfo f = new FileInfo(paths[0]);
//拖放的第一个文件的不能是目录并且扩展名必须是.PP
if (f.Attributes != FileAttributes.Directory && "*.jpg;*.jpeg;*.bmp;*.png".Contains(f.Extension))
{
tbImagePath.Text = paths[0];
pictureBox1.ImageLocation = paths[0];
}
else { MessageBox.Show("不是图片文件或不支持的图片格式!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); }
}
}