Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String имя_файла;
- private void Form1_Load(object sender, EventArgs e)
- {
- var ТекущийКаталог = System.IO.Directory.GetCurrentDirectory();
- имя_файла = ТекущийКаталог + @"\Text.txt";
- }
- private void button1_Click(object sender, EventArgs e)
- {
- try
- {
- var Кодировка = System.Text.Encoding.GetEncoding(1251);
- var Читатель = new System.IO.StreamReader(имя_файла, Кодировка);
- /*
- string fullFile = Читатель.ReadToEnd();
- string[] sep = { "\r\n", "\n" };
- var lines = fullFile.Split(sep, StringSplitOptions.RemoveEmptyEntries);
- richTextBox1.Clear();
- foreach (string line in lines)
- {
- if (int.Parse(line) >= 10 && int.Parse(line) <= 99)
- {
- richTextBox1.Text += line + "\r\n";
- }
- }
- */
- while (!Читатель.EndOfStream)
- {
- string line = Читатель.ReadLine();
- if (int.Parse(line) >= 10 && int.Parse(line) <= 99)
- {
- richTextBox1.Text += line + "\r\n";
- }
- }
- Читатель.Close();
- }
- catch (System.IO.FileNotFoundException Ситуация)
- {
- MessageBox.Show(Ситуация.Message + "\n" + "Нет такого файла", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- catch (Exception Ситуация)
- {
- MessageBox.Show(Ситуация.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement