private void mitExportZipFileForServerToolStripMenuItem_Click(object sender, EventArgs e) { ArrayList sl = dataGridView1.DataSource as ArrayList; if (sl.Count > 0) { if (MessageBox.Show("确认打包" + sl.Count + " records?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { string fd = CTHelper.CommonPath() + "\\ctdbr"; if (!Directory.Exists(fd)) { Directory.CreateDirectory(fd); } progressBar1.Visible = true; progressBar1.Maximum = sl.Count; progressBar1.Value = 0; using (var db = new CTDBEntities()) foreach (tbLabel ts in sl) { progressBar1.Value++; try { //MessageBox.Show(ts.label_id.ToString()); tbLabel lb = db.tbLabel.FirstOrDefault(s => s.label_id == ts.label_id); string src = lb.label_srcfolder; string des = fd + "\\" + lb.label_id + ".zip"; if (File.Exists(des)) { continue; } CTHelper.ZipDirectory(src, des); System.Threading.Thread.Sleep(500); } catch { } } progressBar1.Visible = false; System.Diagnostics.Process.Start(fd); } } }