zzza888

Untitled

Apr 18th, 2014
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void exportFileToolStripMenuItem_Click(object sender, EventArgs e)
  2. {
  3.  
  4. saveFileDialog1.Title = "Save";
  5.  
  6. saveFileDialog1.Filter = "Fisier Text (*.txt)|*.txt|Fisier Word (*.doc)|*.doc";
  7.  
  8. saveFileDialog1.FilterIndex = 1;
  9. saveFileDialog1.FileName = "";
  10.  
  11. saveFileDialog1.OverwritePrompt = true;
  12. saveFileDialog1.ShowDialog();
  13.  
  14. }
  15.  
  16. private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
  17. {
  18. try
  19. {
  20. using (StreamWriter theWriter = new StreamWriter(saveFileDialog1.FileName))
  21. {
  22. foreach (object currentItem in this.listView2.Items)
  23. {
  24.  
  25. // theWriter.Write(currentItem.ToString());
  26. if (currentItem.ToString().Contains("ListViewItem:") == true)
  27. {
  28. theWriter.Write(currentItem.ToString().Remove(0, 15).Replace("}", " "));
  29. }
  30. }
  31. }
  32. using (StreamReader theReader = new StreamReader("fileName.txt"))
  33. {
  34.  
  35.  
  36.  
  37. this.listView2.Items.Add(theReader.ReadLine());
  38.  
  39.  
  40.  
  41. }
  42. saveFileDialog1.OpenFile();
  43. }
  44. catch {}
  45.  
  46. }
RAW Paste Data