예제 #1
0
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFile = new SaveFileDialog
            {
                Filter = "Текстовый файл(*.txt)|*.txt|Бинарный файл(*.bin)|*.bin"
            };

            saveFile.ShowDialog();

            try
            {
                Student student = new Student
                {
                    Name       = nameBox.Text,
                    Age        = Convert.ToInt32(ageBox.Text),
                    University = univerBox.Text,
                    Faculty    = facBox.Text,
                    Speciality = specBox.Text
                };
                MyFileClass.Write(saveFile.FileName, student);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #2
0
        private void BtnOpen_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog
            {
                Filter = "Текстовый файл(*.txt)|*.txt|Бинарный файл(*.bin)|*.bin"
            };

            openFile.ShowDialog();

            MyFileClass.Read(openFile.FileName, out Student student);

            textBox.Clear();
            textBox.AppendText(student?.ShowInfo());
        }
예제 #3
0
        private void BtnDecomp_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog
            {
                Filter = "Все файлы(*.*)|*.*"
            };

            openFile.ShowDialog();

            SaveFileDialog saveFile = new SaveFileDialog
            {
                Filter = "Все файлы(*.*)|*.*"
            };

            saveFile.ShowDialog();

            MyFileClass.Decompress(openFile.FileName, saveFile.FileName, out string message);
            textBox.Text = message;
        }