private void InputInFile_Click(object sender, RoutedEventArgs e) { string name; if (FileName.Text != "") { name = FileName.Text + ".txt"; } else { name = "g.txt"; } bool rez = CreateFile.getInstance().InsertInFile(name, "f.txt"); if (rez) { OutputWindow.Text = "Содержимое файла " + name + ":\n"; StreamReader sr = new StreamReader(name); string line; while ((line = sr.ReadLine()) != null) { OutputWindow.Text += line; OutputWindow.Text += "\n"; } sr.Close(); } else { OutputWindow.Text = "Файл пуст"; } }
private void InputInFile_Click(object sender, RoutedEventArgs e) { string name; if (FileName.Text != "") { name = FileName.Text + ".txt"; } else { name = "g.txt"; } bool rez = CreateFile.getInstance().InsertInFile(name, "f.txt"); if (rez) { OutputWindow.Text = "Содержимое файла " + name + ":\n"; // Смотрите описание коммита пр. 5-6 /* StreamReader sr = new StreamReader(name); * string line; * while ((line = sr.ReadLine()) != null) * { * OutputWindow.Text += line; * OutputWindow.Text += "\n"; * } * sr.Close();*/ string[] stringArray = { "Привет, мир", "п", "аа", "11 тест" }; for (int i = 0; i < stringArray.Length; i++) { OutputWindow.Text += stringArray[i]; OutputWindow.Text += "\n"; } } else { OutputWindow.Text = "Файл пуст"; } }