private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); string filePath; openFileDialog.Filter = "Image files (*.jpg, *.jpeg, *.jpe, *.jfif, *.png) | *.jpg; *.jpeg; *.jpe; *.jfif; *.png"; if (DialogResult.OK == openFileDialog.ShowDialog()) { Image image = Image.FromFile(openFileDialog.FileName); Image result; result = Adder.AddHeaderAndFooter(image); CreateOutputFolder(Path.GetDirectoryName(openFileDialog.FileName)); filePath = Path.GetDirectoryName(openFileDialog.FileName) + "\\Output\\" + Path.GetFileName(openFileDialog.FileName); result.Save(filePath); } }
private void button2_Click(object sender, EventArgs e) { FolderBrowserDialog folderBrowser = new FolderBrowserDialog(); if (DialogResult.OK == folderBrowser.ShowDialog()) { string path = folderBrowser.SelectedPath; string[] files = Directory.GetFiles(path); CreateOutputFolder(path); foreach (string file in files) { Image result; string filePath; result = Adder.AddHeaderAndFooter(Image.FromFile(file)); filePath = path + "\\Output\\" + Path.GetFileName(file); result.Save(filePath); } } }