public static IStegano CreateObject(string pathFile) { IStegano obj = null; if (File.Exists(pathFile)) { string extension = Path.GetExtension(pathFile); switch (extension) { case ".docx": obj = new SteganoDOCX(pathFile); break; case ".rtf": obj = new SteganoRTF(pathFile); break; case ".txt": obj = new SteganoTXT(pathFile); break; default: throw new ArgumentException(); } } return(obj); }
private void button2_Click(object sender, EventArgs e) { try { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { string fileName = openFileDialog.FileName; SteganoContainerDecrypt = ObjectFactory.CreateObject(fileName); SteganoContainerDecrypt.GetFileData(); } } catch { MessageBox.Show("Анта бака!\n Ошибка при считывании файла-контейнера!\n", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }