private void button1_Click(object sender, EventArgs e) { using (OpenFileDialog dialog = new OpenFileDialog()) { if (dialog.ShowDialog(this) == DialogResult.OK) { string sFileName = dialog.FileName; pathFolder = sFileName; label3.Text = pathFolder; label3.Show(); firstFile = DataFile.Load(dialog.FileName); if (firstFile.CheckStation()) { MessageBox.Show("Файла с дневни данни трябва да съдържа само една станция!"); } } } }
/// <summary> /// Returns true if this entries contains the same years as the entries of the given file /// If one file have one more or less year it returns false /// </summary> /// <param name="otherFile"></param> /// <returns></returns> public bool CheckYears(DataFile otherFile) { string[] allPossibleYearsOfThisFile = this.GetYears(); string[] allPossibleYearsOfTheOtherFile = otherFile.GetYears(); if (allPossibleYearsOfThisFile.Length != allPossibleYearsOfTheOtherFile.Length) { return(false); } else { foreach (var year in allPossibleYearsOfThisFile) { if (!allPossibleYearsOfTheOtherFile.Contains(year)) { return(false); } } } return(true); }
private void button2_Click(object sender, EventArgs e) { using (OpenFileDialog dialog = new OpenFileDialog()) { if (dialog.ShowDialog(this) == DialogResult.OK) { string sFileName = dialog.FileName; pathFolder2 = sFileName; label4.Text = pathFolder2; label4.Show(); string[] lines = System.IO.File.ReadAllLines(dialog.FileName); int i = 0; secondFile = DataFile.Load(dialog.FileName); if (secondFile.CheckStation()) { MessageBox.Show("Файла с месечни данни трябва съдържа само една станция!"); return; } } } }