Beispiel #1
0
 /// <summary>
 /// The save pops.
 /// </summary>
 /// <param name="fileName">
 /// The file name.
 /// </param>
 /// <param name="list">
 /// The list.
 /// </param>
 public static void SavePops(string fileName, PopList list)
 {
     using (var writer = new StreamWriter(
                new FileStream(fileName, FileMode.OpenOrCreate, FileAccess.Write)))
     {
         foreach (var pop in list)
         {
             writer.WriteLine(ToFileString(pop));
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// The get pops.
        /// </summary>
        /// <param name="fileName">
        /// The file name.
        /// </param>
        /// <returns>
        /// The <see cref="PopList"/>.
        /// </returns>
        public static PopList GetPops(string fileName)
        {
            var list = new PopList();

            using (var reader = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read)))
            {
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    TryParse(line, out var pop);
                    list.Add(pop);
                }
            }

            return(list);
        }
Beispiel #3
0
        /// <summary>
        /// The open tool strip menu item_ click.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (var open = new OpenFileDialog())
            {
                open.CheckPathExists  = true;
                open.CheckFileExists  = true;
                open.Filter           = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                open.InitialDirectory = @"C:\";

                var result = open.ShowDialog();

                if (result == DialogResult.OK)
                {
                    var fileName = open.FileName;
                    PopList.Delim = this.DeliminatorTextBox.Text[0];
                    this.Pops     = PopList.GetAll(fileName);
                    this.BindPops();
                } // else, the user closed the dialog box, DoNothing();
            }
        }