public void SaveKey(KeyData key) { using (StreamWriter sw = new StreamWriter(licensePath, true)) { sw.WriteLine(key.INN + " " + key.Key + " " + key.Year); } }
public List <KeyData> LoadKeyData() { List <KeyData> keyData = new List <KeyData>(); if (!File.Exists(licensePath)) { File.Create(licensePath).Close(); return(keyData); } using (StreamReader sr = new StreamReader(licensePath)) { string line; while ((line = sr.ReadLine()) != null) { string [] keys = line.Split(' '); KeyData key = new KeyData(keys[0], keys[2], keys[1]); if (CheckKey(key.Key, new UserData(key.INN, key.Year))) { keyData.Add(key); } } } return(keyData); }