Загрузка данных


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Сидоренко_Сохарев
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.IO.StreamReader sr;
            try
            {
                sr = new System.IO.StreamReader(Application.StartupPath + "\\usd.txt", System.Text.Encoding.GetEncoding(1251)); 
                DateTime dateStart = monthCalendar1.SelectionStart;
                DateTime dateEnd = monthCalendar1.SelectionEnd;

                string st1, st2 = "";
                DateTime date;
                listBox1.Items.Clear();
                while (!sr.EndOfStream)
                {
                    st1 = sr.ReadLine(); 
                    date = System.Convert.ToDateTime(st1);
                    st2 = sr.ReadLine();
                    if ((date >= dateStart) &&
                    (date <= dateEnd))
                    {
                        listBox1.Items.Add(st1 + " " + st2);

                    }
                }
                sr.Close();
                if (listBox1.Items.Count == 0)
                {
                    listBox1.Items.Add("--- нет данныX -");
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("Ошибка доступа к þайлу данныx\n" + exc.ToString(), "Kотировки", MessageBoxButtons.OK, MessageBoxIcon.Error);
                button1.Enabled = false;
            }
        }



        private void button2_Click(object sender, EventArgs e)
        {
            Form form = new Form1();
            form.Show();
        }
    }
}