Exemple #1
0
 public void SaveKey(KeyData key)
 {
     using (StreamWriter sw = new StreamWriter(licensePath, true))
     {
         sw.WriteLine(key.INN + " " + key.Key + " " + key.Year);
     }
 }
Exemple #2
0
        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);
        }