public void ExportToTxtFile(ExportFileDTO fileData) { using var file = new StreamWriter( Path.Combine(Directory.GetCurrentDirectory(), fileData.FileName), false, Encoding.UTF8 ); file.WriteLineAsync($"Entered Phone: {fileData.Phone}"); file.WriteLineAsync($"Entered UserName: {fileData.UserName}"); }
private void sbmtBtn_Click(object sender, EventArgs e) { var exportData = new ExportFileDTO { FileName = $"{DateTime.Now.Hour}hh-{DateTime.Now.Minute}mm-{DateTime.Now.Second}ss", Phone = string.IsNullOrEmpty(this.txtPhone.Text) ? string.Empty : this.txtPhone.Text, UserName = string.IsNullOrEmpty(this.txtName.Text) ? string.Empty : this.txtName.Text }; _exportService.ExportToTxtFile(exportData); MessageBox.Show($"Successfully written! Check your directory project folder."); Application.Exit(); }