/// <summary> /// 打开拖入文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmhuitu_DragDrop(object sender, DragEventArgs e) { //获取第一个文件名 fileName = (e.Data.GetData(DataFormats.FileDrop, false) as String[])[0]; if (Directory.Exists(fileName)) { DirectoryInfo dir1 = new DirectoryInfo(fileName); if (dir1.GetFiles("1.png", SearchOption.AllDirectories).Length < 2) { fileName = Path.Combine(fileName, "1.png"); if (File.Exists(fileName) == false) { fileName = string.Empty; MessageBox.Show("该文件夹不包含节点文件!"); } } else { tongji fr = new tongji(fileName, this); fr.Show(); this.Hide(); } } if (File.Exists(fileName)) { try { //载入图片 this.pictureBox1.ImageLocation = fileName; //这里开起了个新线程,用来载入config文件 //如不开启新线程,程序会先移动参数框,再载入图片。 ThreadStart ths = new ThreadStart(findconfigthr); Thread threadA = new Thread(ths); threadA.IsBackground = true; threadA.Priority = ThreadPriority.Lowest; threadA.Start(); //this.findconfig(); } catch (Exception) { MessageBox.Show("文件格式不对"); } } }
private void button7_Click(object sender, EventArgs e) { tongji frm = new tongji(); frm.Show(); }