Beispiel #1
0
        public void Save(string filename, List <VCard> vCardList)
        {
            string serialized = String.Empty;

            foreach (var vCard in vCardList)
            {
                serialized += vCard.Serialize();
            }
            try
            {
                File.WriteAllText(filename, serialized, new UTF8Encoding(false));
                SaveFileComplete?.Invoke(this, new EventArgs());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка сохранения", MessageBoxButton.OK);
            }
        }
Beispiel #2
0
 public void SaveAll(string filename, List <VCard> vCardList)
 {
     foreach (var vCard in vCardList)
     {
         var serialized = vCard.Serialize();
         var _filename  = filename;
         try
         {
             while (File.Exists(_filename))
             {
                 Random rnd = new Random();
                 _filename = Path.GetDirectoryName(_filename) + @"\" + Path.GetFileNameWithoutExtension(_filename) + rnd.Next(1, 10) + Path.GetExtension(filename);
             }
             File.WriteAllText(_filename, serialized, new UTF8Encoding(false));
             SaveFileComplete?.Invoke(this, new EventArgs());
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Ошибка сохранения", MessageBoxButton.OK);
         }
     }
 }