0

I am new to developing and I am creating an AddressBook using c#.

I am trying to save my data collection using my DataLayer class into a txt file. The data collection is displayed in a DataGridView which is located in my AddressBook GUI

I would like to save the data collection without touching the DataGridView.

What would be the best way to do this, and could I have an example please?

  • http://en.wikipedia.org/wiki/Serialization – I4V May 30 '13 at 09:21
  • http://msdn.microsoft.com/en-us/library/6ka1wd3w.aspx – fGo May 30 '13 at 09:32
  • just consider each address is a line in a text file. Then iterate over your list and write the data in the format you want. Just follows the tons of examples of file manipulation on the net – fGo May 30 '13 at 09:35

1 Answers1

0

Here AddressBook is array of string.
You can write full array using the below give method of File class.

        File.WriteAllLines(@"C:\Addresses.txt", AddressBook);
Palak.Maheria
  • 1,497
  • 2
  • 15
  • 32