コード例 #1
0
        /// <summary>
        /// Считывание и привязка данных при загрузке формы
        /// </summary>
        private void Form1_Load(object sender, EventArgs e)
        {
            listF = fa.OpenF(pathF, listF);
            listB = fa.OpenB(pathB, listB);
            listT = fa.OpenT(pathT, listT);

            personListBindingSource.DataSource  = listF;
            personListBindingSource1.DataSource = listT;
            personListBindingSource2.DataSource = listB;
        }
コード例 #2
0
        public void SaveT(string pathT, TennisPlayerList listT)
        {
            BinaryFormatter bf = new BinaryFormatter();

            if (!File.Exists(pathT))
            {
                Stream stream = File.Create(pathT);
                stream.Close();
            }
            using (Stream stream = new FileStream(pathT, FileMode.Open, System.IO.FileAccess.Write, FileShare.None))
            {
                bf.Serialize(stream, listT);
            }
        }
コード例 #3
0
 public TennisPlayerList OpenT(string pathT, TennisPlayerList listT)
 {
     if (File.Exists(pathT))
     {
         Stream          stream = File.Open(pathT, FileMode.Open);
         BinaryFormatter b      = new BinaryFormatter();
         listT = (TennisPlayerList)b.Deserialize(stream);
         stream.Close();
         return(listT);
     }
     else
     {
         Stream stream = File.Create(pathT);
         stream.Close();
         return(null);
     }
 }