/// <summary> /// 保存生成的二维码 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (qrBitmap == null || triggerDrag == false) { MessageBox.Show("未生成二维码", "出错了!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //提示 正在保存错误的二维码 if (!triggerChecked) { DialogResult drTip = MessageBox.Show("正在保存不可用的二维码。是否继续?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (drTip != DialogResult.OK) { return; } } List <object> formatList = FormatFactory.GetSelectFormat(comboBox1.SelectedItem.ToString()); FileDialog fd = new SaveFileDialog(); fd.Title = "请选择要保存的位置"; fd.AddExtension = false; fd.Filter = "所有文件|*.*"; if (fd.ShowDialog() == DialogResult.OK) { string thisImgPath = fd.FileName + formatList[0]; qrBitmap.Save(thisImgPath, (ImageFormat)formatList[1]); DialogResult dr = MessageBox.Show("保存成功!是否打开文件目录?", "提示", MessageBoxButtons.OKCancel , MessageBoxIcon.Asterisk); if (dr == DialogResult.OK) { Process pr1 = Process.Start("Explorer.exe", "/select," + thisImgPath); } } //清理所有元素 formatList.Clear(); BtnMakeQr.Text = "生成二维码"; }