Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void SaveButton_Click(object sender, RoutedEventArgs e)
- {
- string fileName = @"D:projectsPersonInfosFilesPersonInfos_Copy.txt";
- PersonInfosTable.ConvertToTXTFile(fileName);
- }
- public void ConvertToTXTFile(string fileName)
- {
- StringBuilder sb = new StringBuilder();
- System.Text.Encoding Output = null;
- Output = System.Text.Encoding.Default;
- foreach (PersonInfos personinfos in PersonInfoDetails)
- {
- if (PersonInfos.SelectCheckBox == true)
- {
- string line = String.Format("L§" + personinfos.FirstName + "§" + personinfos.LastName + "§");
- sb.AppendLine(line);
- StreamWriter file = new StreamWriter(fileName);
- file.WriteLine(sb);
- file.Close();
- }
- }
- }
- public void ConvertToTXTFile(string fileName)
- {
- StringBuilder sb = new StringBuilder();
- System.Text.Encoding Output = System.Text.Encoding.Default;
- foreach (PersonInfos personinfos in PersonInfoDetails)
- {
- // Collect every personinfos selected in the stringbuilder
- if (personinfos.SelectCheckBox == true)
- {
- string line = String.Format("L§" + personinfos.FirstName + "§" + personinfos.LastName + "§");
- sb.AppendLine(line);
- }
- }
- // Now write the content of the StringBuilder all together to the output file
- File.WriteAllText(filename, sb.ToString())
- }
- if (personInfos.SelectCheckBox == true)
- {
- // ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement