예제 #1
0
파일: Form1.cs 프로젝트: Andriy1236/Gl_Task
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (label1.Text == string.Empty)
                {
                    MessageBox.Show("Please, add folder for serialization");
                    return;
                }
                if (label2.Text == string.Empty)
                {
                    MessageBox.Show("Please, add a folder for serialized file");
                    return;
                }
                SerializeManager serializeManager = new SerializeManager();
                var folder = serializeManager.GetFolder(label1.Text);
                serializeManager.SerializeFolder(folder, label2.Text);

                MessageBox.Show("The folder was serialized");
            }
            catch (OutOfMemoryException)
            {
                MessageBox.Show("The folder size too big");
            }
            catch (UnauthorizedAccessException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                label1.Text = string.Empty;
                label2.Text = string.Empty;
            }
        }