private void btnStartTransfer_Click(object sender, EventArgs e) { // Generate file name try { String strFileName = strDataDirectory + System.Net.Dns.GetHostName() + "-Transfer-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ((this.txtWorkID.Text.Length != 0) ? "-" : "") + this.txtWorkID.Text.ToString() + ".csv"; // Open Form 2 using (Form2Transfer f2transfer = new Form2Transfer(strFileName)) { f2transfer.ShowDialog(); this.loadFileNamesInListBox(); } } catch (Exception ex) { MessageBox.Show("Cannot generate file name and launch app.\n" + ex.Message); } }