private void btnRun_Click(object sender, System.EventArgs e) { foreach (System.IO.FileInfo f in clbSrc.CheckedItems) { //------------------------------------------------------------------// System.IO.Stream stream = null; try { ReportBuilder builder = new ReportBuilder(); Report activeReport; builder.Build(f.FullName); activeReport = builder.Report; activeReport.Location = new Point((this.Width - activeReport.Width) / 2, 0); //***// stream = new System.IO.FileStream(fbd.SelectedPath + "\\" + f.Name + ".xml", System.IO.FileMode.Create); //ReportBuilder rb = new ReportBuilder(r); XmlSerializer xml = new XmlSerializer(/*rb*/ builder.GetType()); xml.Serialize(stream, /*rb*/ builder); stream.Close(); //------------------------------------------------------------------// clbDst.SetItemChecked(clbDst.FindStringExact(f.Name), true); } catch (Exception err) { if (stream != null) { if (stream.CanWrite) { stream.Close(); } } } } }