Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. private void SaveButton_Click(object sender, RoutedEventArgs e)
  2. {
  3. string fileName = @"D:projectsPersonInfosFilesPersonInfos_Copy.txt";
  4. PersonInfosTable.ConvertToTXTFile(fileName);
  5. }
  6.  
  7. public void ConvertToTXTFile(string fileName)
  8. {
  9. StringBuilder sb = new StringBuilder();
  10. System.Text.Encoding Output = null;
  11. Output = System.Text.Encoding.Default;
  12.  
  13. foreach (PersonInfos personinfos in PersonInfoDetails)
  14. {
  15. if (PersonInfos.SelectCheckBox == true)
  16. {
  17. string line = String.Format("L§" + personinfos.FirstName + "§" + personinfos.LastName + "§");
  18. sb.AppendLine(line);
  19.  
  20. StreamWriter file = new StreamWriter(fileName);
  21. file.WriteLine(sb);
  22.  
  23. file.Close();
  24. }
  25. }
  26. }
  27.  
  28. public void ConvertToTXTFile(string fileName)
  29. {
  30. StringBuilder sb = new StringBuilder();
  31. System.Text.Encoding Output = System.Text.Encoding.Default;
  32. foreach (PersonInfos personinfos in PersonInfoDetails)
  33. {
  34. // Collect every personinfos selected in the stringbuilder
  35. if (personinfos.SelectCheckBox == true)
  36. {
  37. string line = String.Format("L§" + personinfos.FirstName + "§" + personinfos.LastName + "§");
  38. sb.AppendLine(line);
  39. }
  40. }
  41.  
  42. // Now write the content of the StringBuilder all together to the output file
  43. File.WriteAllText(filename, sb.ToString())
  44. }
  45.  
  46. if (personInfos.SelectCheckBox == true)
  47. {
  48. // ...
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement