public void Add()
{
const string path = "C:/Users/User/Desktop/mardik.txt";
FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
BinaryFormatter bf = new BinaryFormatter();
List<Person> all = bf.Deserialize(fs) as List<Person>;
fs.Close();
Console.WriteLine("Enter new user's data with comma");
string text = Console.ReadLine();
string[] segments = text.Split(',');
string a = segments[0];
int b;
bool hajoxvec = int.TryParse(segments[1], out b);
if (!hajoxvec)
{
Console.WriteLine("Please try again");
this.Add();
}
else
{
all.Add(new Person(a, b));
}
foreach (Person item in all)
{
Console.WriteLine(item.name + " " + item.age);
}
fs.Close();
}
it's working, now i need only to save my adding data.