namespace JsonCanonicalizer.UI; public partial class OneFileTaskForm : Form { public OneFileTaskForm() { InitializeComponent(); } private void btnSrcFile_Click(object sender, EventArgs e) { dlgSrcFile.FileName = txtSrcFile.Text; if (dlgSrcFile.ShowDialog() == DialogResult.OK) { txtSrcFile.Text = dlgSrcFile.FileName; } } private void btnDstFile_Click(object sender, EventArgs e) { dlgDstFile.FileName = txtDstFile.Text; if (dlgDstFile.ShowDialog() == DialogResult.OK) { txtDstFile.Text = dlgDstFile.FileName; } } private void btnDoIt_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(txtSrcFile.Text)) { MessageBox.Show("Не выбран исходный файл", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (String.IsNullOrWhiteSpace(txtDstFile.Text)) { MessageBox.Show("Не задан файл результата", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!File.Exists(txtSrcFile.Text)) { MessageBox.Show("Исходный файл не существует", Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { using Stream src = new FileStream(txtSrcFile.Text, FileMode.Open); using Stream dst = new FileStream(txtDstFile.Text, FileMode.Create); BL.Canonicalizer.Canonicalize(src, dst); MessageBox.Show("Готово", Text, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }